Forum Moderators: phranque
Lately I work on my site with apache mod rewrite, a new site.
I've change my php script to output htm links.
Then I used mod rewrite with these htm links to execute with corresponding php query
example:
RewriteRule ^(.*)-page-([0-9]+)\.htm$ file.php?query=$1&start=$2 [L]
If I put the end with [R=301,L] it will redirect these htm link the the original php file, so I don't put anything except [L]
I got sitemap error message in google webmaster tool.
"we've test several url from sitemap, the url is redirecting, not a final destination."
Something close like that, I don't remember the exact one.
Maybe this is because of these htm links not end with [R=301,L].
Then I put this after several RewriteRule like above
RewriteRule ^/(.*)\.htm$ $1.php [R=301,L]
RewriteRule ^/(.*)\.php$ \/$1.htm [R=301,L]
I check the header status code, always return me with 200, no one with 302 or 301.
Do I've another solution to change the last two rewrite rule? so I can get the 301 status.
I got no error message in google, is this fixed yet?
Do I missed something here? Or I already on track?
Thanks in advance
If it is 301 or 302 then you DO have a redirect, and need to fix it so that it does not redirect.
If it is '200 OK' then the site is working right.
You need to check http and https requests for both www and non-www here.
Only one should return a 200 OK. The others should redirect or fail.
You need a more restrictive pattern than (.*) in your pattern. That matches the 'whole URL to the very end' and then has to backoff and retry many times to find a match.
You do need to add a redirect such that if someone requests a .php URL they are redirected to request the .html URL. That redirect should use a RewriteRule, with [R=301,L] flags, and should force the canonical domain at the same time. This new redirect should be listed before your existing rewrite.
See also: [webmasterworld.com...]