LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
Search this Thread
Old 12-12-2006, 03:36 PM   #1
deesto
Member
 
Registered: May 2002
Location: NY, USA
Distribution: FreeBSD, Fedora, RHEL, Ubuntu; OS X, Win; have used Slackware, Mandrake, SuSE, Xandros
Posts: 448

Rep: Reputation: 31
Question cleaning up apache RewriteRule entries


I have a whole slew of RewriteRules that I'm sure are not optimal. In a nutshell, I would like any requests to:
/dir1/dir2/dir3/file
to go to:
/directory/dir2/dir3/file.html
... but keep the format of the original request (same directory structure, no .html extension).

I'd also like any requests that don't specify a file (/dir1/dir2/dir3) to go to a standard page (Home.html).

And any requests that only specify the first directory (/dir1) should go to a specific standard page (/directory/dir2/dir3/Home.html).

Here's what we have so far, which seems to catch most cases but is a mess:

Code:
<VirtualHost *:80>
    ServerAdmin webmaster@webserver
    ServerName webserver
    ReWriteEngine On
    RewriteLogLevel 2
    RewriteRule  ^/dir1/dir2/dir3/misc/(\w+)(/.*)$  /directory/$1/misc/$1$2 [P,L]
    RewriteRule  ^/dir1/dir2/dir3/(\w+)/misc(/.*)$  /directory/$1/misc$2 [P,L]
    RewriteRule  ^/dir1/dir2/misc/(\w+)(/.*)$  /directory/$1/misc/$1$2 [P,L]
    RewriteRule  ^/dir1/dir2/(\w+)/misc(/.*)$  /directory/$1/misc$2 [P,L]
    RewriteRule  ^/dir1/misc/(\w+)(/.*)$  /directory/$1/misc/$1$2 [P,L]
    RewriteRule  ^/dir1/(\w+)/misc(/.*)$  /directory/$1/misc$2 [P,L]
    RewriteRule  ^/dir1/dir2/dir3/(\w+)/(\w+).html$  /directory/$1/$2.html [P,L]
    RewriteRule  ^/dir1/dir2/dir3/(\w+).html$  /directory/Main/$1.html [P,L]
    RewriteRule  ^/dir1/dir2/dir3/(\w+)/(\w+)$  /directory/$1/$2.html [P,L]
    RewriteRule  ^/dir1/dir2/dir3/(\w+)/?$  /directory/$1/Home.html [P,L]
    RewriteRule  ^/dir1/dir2/dir3/?$  /directory/Main/Home.html [P,L]
    RewriteRule  ^/dir1/dir2/(\w+)/(\w+).html$  /directory/$1/$2.html [P,L]
    RewriteRule  ^/dir1/dir2/(\w+).html$  /directory/Main/$1.html [P,L]
    RewriteRule  ^/dir1/dir2/(\w+)/(\w+)$  /directory/$1/$2.html [P,L]
    RewriteRule  ^/dir1/dir2/(\w+)/?$  /directory/$1/Home.html [P,L]
    RewriteRule  ^/dir1/dir2/?$  /directory/Main/Home.html [P,L]
    RewriteRule  ^/dir1/(\w+)/(\w+).html$  /directory/$1/$2.html [P,L]
    RewriteRule  ^/dir1/(\w+).html$  /directory/Main/$1.html [P,L]
    RewriteRule  ^/dir1/(\w+)/(\w+)$  /directory/$1/$2.html [P,L]
    RewriteRule  ^/dir1/(\w+)/?$  /directory/$1/WebHome.html [P,L]
    RewriteRule  ^/dir1/?$  /directory/Main/Home.html [P,L]
    ProxyPass /directory http://webserver/directory
    ProxyPassReverse /directory  http://webserver/directory
</VirtualHost>
Is there a better way?
 
  


Reply

Tags
apache, configuration, rewriterule, server


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help w/ Apache htaccess (RewriteRule) bhuwan Programming 1 03-16-2006 06:06 AM
Apache entries - Hacked?? lawadm1 Linux - Security 2 11-27-2005 08:49 PM
Apache ReWriteRule, ProxyPassReverse, and Allow From directives yakkerty Linux - Networking 3 06-24-2004 01:21 PM
Suspicious looking Apache log entries linuxpyro Linux - Security 4 04-25-2004 02:54 PM
Apache RewriteRule is driving me nuts ijsman77 Linux - Software 3 04-07-2004 02:25 AM


All times are GMT -5. The time now is 10:43 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration