Welcome to WebmasterWorld Guest from 220.127.116.11
mod_rewrite seems to be topic of the month here ;-)
I wish to redirect page1.html to page2.html as in dave's tutorial [webmasterworld.com]
however using exactly what he has suggested:
RewriteRule ^page1\.html$ page2.html [R=301,L]
I get this error in my logs:
File does not exist:
The path appears to be duplicated.
I then read a post from Andreas about the [R] flag being an external redirect needing a full URI, whereas without the [R] flag it is internal.
If I leave the R=301 out of Dave's example, it works perfectly, but of course the new URL is not shown in the browser, which I want.
But if I use [R=301,L] I have to either use /page2.html (with the trailing slash), or specify the full URI http://www.mydomain.com/page2.html or to specify RewriteBase /
Can someone please confirm this, as I am rather confused?
That´s right assuming you use mod_rewrite [httpd.apache.org] in directory context (.htaccess files). /page2.html will work since it being a root relative path mod_rewrite [httpd.apache.org] will not need to use a URL-prefix other than [thishost:thisport...] which it had to try to deduce from the file path. Using the full URI mod_rewrite [httpd.apache.org] will chop off the [thishost:thisport...] and the situation is the same as with the root relative path. When using RewriteBase [httpd.apache.org] you save mod_rewrite [httpd.apache.org] from having to deduce the URI-prefix from the file path by setting it explicitly. So RewriteBase [httpd.apache.org] / will again rewrite to /page2.html.