homepage Welcome to WebmasterWorld Guest from 54.205.106.111
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
yet another mod_rewrite one
external URI vs. internal [R ¦ L]
jamie




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

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

 

andreasfriedrich




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


>>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

jamie




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

thanks andreas, all clear now :-)

regards James

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved