What's wrong with my .htaccess? Trying to simplify actual code

Posted by AlexV on Server Fault See other posts from Server Fault or by AlexV
Published on 2011-01-04T20:25:02Z Indexed on 2011/01/04 20:55 UTC
Read the original article Hit count: 231

Filed under:
|

This is my actual .htaccess:

#If the requested URI does not end with an extension
RewriteCond %{REQUEST_URI} !\.(.*)

#If the requested URI is not in an excluded location
RewriteCond %{REQUEST_URI} !^/(excluded1|excluded2)/

#Then serve the URI via the mapper
RewriteRule .* /seo-urls/seo-urls-mapper.php?uri=%{REQUEST_URI} [L,QSA]


#If the requested URI ends with .php*
RewriteCond %{REQUEST_URI} \.php.*$ [NC]

#If the requested file is not seo-urls-mapper.php (avoid .htaccess loop)
RewriteCond %{REQUEST_FILENAME} (?<!seo-urls-mapper)\.php.*$

#Then serve the URI via the mapper
RewriteRule .* /seo-urls/seo-urls-mapper.php?uri=%{REQUEST_URI} [L,QSA]

Since all conditions are compatibles except the 1st ones (no extension and *.php* match) all I should have to do is to add the [OR] condition to these 2 lines, but when I'm adding it it's not working (my no extension rule don't work anymore). This is my new (not working) code:

#If the requested URI does not end with an extension OR if the URI ends with .php*
RewriteCond %{REQUEST_URI} !\.(.*) [OR]
RewriteCond %{REQUEST_URI} \.php.*$ [NC]

#If the requested file is not seo-urls-mapper.php (avoid .htaccess loop)
RewriteCond %{REQUEST_FILENAME} (?<!seo-urls-mapper)\.php.*$

#If the requested URI is not in an excluded location
RewriteCond %{REQUEST_URI} !^/(excluded1|excluded2)/

#Then serve the URI via the mapper
RewriteRule .* /seo-urls/seo-urls-mapper.php?uri=%{REQUEST_URI} [L,QSA]

Hopefully someone will be able to clarify this issue... I guess I don't fully understand the use of [OR]. Thanks!

© Server Fault or respective owner

Related posts about mod-rewrite

Related posts about .htaccess