Reputation: 2098
I know this must have an answer somewhere around here, but I am unable to find/locate it.
There is a typical 301 redirection rule in the same domain:
Redirect 301 /path/to/strange-url.htm /path/to/new/canonical-url.htm
Later on htaccess file, there is a rewrite rule for the canonical-url
RewriteRule ^([^/]+)/([^/]+)([^/]+)/([^-]+)-([^.]+)\.htm$ php/page.php?var1=$1&var2=$2&var3=$3&var4=$4&var5=$5 [NC,L]
Problem is that as soon as the 301 redirect activates, my new url becomes:
/path/to/new/canonical-url.htm?var1=xxxx&var2=xxxx&var3=xxxx&var4=xxxx&var5=xxxx
How can I avoid this and maintain only the clean url: /path/to/new/canonical-url.htm
?
Upvotes: 0
Views: 490
Reputation: 2098
ok i finally found a working solution
I changed all Redirect 301 rules to RewriteRule [R=301,L], so:
Redirect 301 /path/to/strange-url.htm /path/to/new/canonical-url.htm
becomes
RewriteRule ^/path/to/strange-url.htm http://www.example.com/path/to/new/canonical-url.htm [R=301,L]
Also, I have moved all former redirects before the actual rewrites
Upvotes: 1
Reputation: 1309
Seems that you have a loop, try to add condition on requested URI, like:
RewriteCond %{REQUEST_URI} !^php/page.php
RewriteRule ^([^/]+)/([^/]+)([^/]+)/([^-]+)-([^.]+)\.htm?$ php/page.php?var1=$1&var2=$2&var3=$3&var4=$4&var5=$5 [NC,L]
Upvotes: 0