Welcome to WebmasterWorld Guest from 54.161.110.186

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

yet another mod_rewrite one

external URI vs. internal [R ¦ L]

     
2:47 pm on Mar 21, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi,

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:

RewriteEngine on
RewriteRule ^page1\.html$ page2.html [R=301,L]

I get this error in my logs:
File does not exist:
/usr/local/apache/sites/mydomain.com/htdocs/ usr/local/apache/sites/mydomain.com/htdocs/page2.html

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.

So...

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?

Many thanks

3:02 pm on Mar 21, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member




>>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 [httpd.apache.org] /

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.

Andreas

3:13 pm on Mar 21, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



thanks andreas, all clear now :-)

regards James

 

Featured Threads

Hot Threads This Week

Hot Threads This Month