[GRLUG] mod_rewrite problem

David Pembrook david at pembrook.net
Mon Aug 8 11:54:08 EDT 2011


I have something weird going on using mod rewrite on apache 2.2.9.

The goal here is to serve up multiple web sites using the same code but 
with each site having its own images, css, and javascript directories.

The first rewrite rule rewrites /images/file.png into /domains/[domain 
name]/images/file.png. That part works fine except [L] should stop 
processing the rewrite rules but its not.

    Options -Indexes

    RewriteEngine On
    RewriteBase /

    RewriteRule ^(images|css|js)/(.*)$ domains/%{SERVER_NAME}/$1/$2 [L]
    RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]


the first rewrite rule works fine if I comment the second rewrite rule. 
I can even see the results of the first rewrite rule in the $_GET 
variable when the second rule functions. The first rule does rewrite the 
URL. It just doesn't stop processing.

A work around since the rewritten directories don't contain php or html 
is this:

    RewriteRule ^(images|css|js)/(.*)$ domains/%{SERVER_NAME}/$1/$2 [L]
    RewriteRule        ^(.*)\.(php|htm|html)$         index.php?q=$1    
                         [L,QSA]

but then I can't have /about it must be /about.htm or about.php etc

I'm having the same issue regardless if I use the .htaccess file or the 
apache configuration files. I also have not left the rewrite rules in 
both at the same time.

Dave

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://shinobu.grlug.org/pipermail/grlug/attachments/20110808/3e65b51a/attachment.html>


More information about the grlug mailing list