redirecting all pages but one in the same way

Using mod_rewrite to handle various content issues

redirecting all pages but one in the same way

Postby TerraFrost » Wed May 30, 2007 6:18 pm

Say I have the following .htaccess file:

Code: Select all
RewriteEngine on
RewriteRule (a|b|c)/(|index\.html) index2.html?type=$1
RewriteRule (a|b|c)/(.*) $2?type=$1


What I would expect this rule to rewrite http://www.domain.tld/a/ to
http://www.domain.tld/index2.html and http://www.domain.tld/a/image.ext
to http://www.domain.tld/image.ext.

Unfortunately, that's not happening. What is happening is that
everything in /a/ is being rewritten to index2.html - not just / and
index.html, itself.

My question is... what am I doing wrong and what I can I do to fix
it?

Thanks!
TerraFrost
 
Posts: 3
Joined: Wed Nov 10, 2004 8:40 pm

Postby richardk » Thu May 31, 2007 9:41 am

The pattern needs anchoring.

Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteRule ^(a|b|c)(/(index\.html)?)?$ /index2.html?type=$1 [QSA,L]
RewriteRule ^(a|b|c)/(.+)$              /$2?type=$1          [QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Content

Who is online

Users browsing this forum: No registered users and 17 guests

cron