Forum Moderators: phranque
I have a site with the following line in the .htaccess file:
RewriteRule ^(.*)add/ $1add_url.php
This basically rewrites /add/1/2/add_url.php to /add/1/2.php.
What I want to do is make all of those /add pages redirect to /add/1/1.php.
So this is what I have so far:
RewriteCond %{REQUEST_FILENAME}!^add/1/1.php
RewriteRule ^(.*)add/([0-9]+)/([0-9]+).php ^add/1/1.php [R=301,L]
RewriteRule ^(.*)add/ $1add_url.php
The condition says don't rewrite it if the request is to add/1/1.php itself, and then rewrite it if it isn't.
For some reason this is still getting thrown into a loop and doesn't resolve to add/1/1.php.
Any ideas? Thanks in advance.
I'd suggest you test REQUEST_URI, and include the leading slash in the pattern:
RewriteCond %{REQUEST_URI} [b]!^/a[/b]dd/1/1.php
Jim