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

Apache Web Server Forum

    
301 Redirect: [R=301,L] or [R=permanent,L]
Which one is correct?
iProgram




msg:1499274
 4:12 am on Apr 18, 2004 (gmt 0)

Hi, I want to change my domain name from www.abc.com to www.123.com (same IP address). After searched this forum, I found a lot of methods about 301 redirect in .htaccess. The followings are two versions:
1.
RewriteEngine On
Options +FollowSymlinks
RewriteRule ^(.*)$ [123.com...] [R=301,L]

2.
RewriteEngine on
Options +FollowSymlinks
RewriteRule ^(.*)$ [123.com...] [R=permanent,L]

So which one is correct?

 

iProgram




msg:1499275
 4:13 am on Apr 18, 2004 (gmt 0)

Sorry, I forget to search Apach DOC. You may find the answer here:
[httpd.apache.org...]
(Search 'permanent')

bcc1234




msg:1499276
 5:04 am on Apr 18, 2004 (gmt 0)

301 and permanent are the same thing.

jdMorgan




msg:1499277
 5:08 am on Apr 18, 2004 (gmt 0)

Yes, they are equivalent.

Be aware that the code you found has a bug. The first two directives are reversed. The code order must be:

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.*)$ http://www.123.com/$1 [R=301,L]

Some servers may already be configured with FollowSymLinks enabled. If so, then the Options +FollowSymlinks directive won't be needed. But if it is needed, it must come before RewriteEngine on.

Jim

iProgram




msg:1499278
 5:39 am on Apr 18, 2004 (gmt 0)

All my current .htaccess files use RewriteEngine before Options +FollowSymlinks, without any problem. But if I remove the Options +FollowSymlinks line, I will get a 403 forbidden error. Does this mean my server was configured with FollowSymLinks disabled? I tried to switch these two lines, no effect. Do I still need to update all my .htaccess files?

jdMorgan




msg:1499279
 3:06 pm on Apr 21, 2004 (gmt 0)

> All my current .htaccess files use RewriteEngine before Options +FollowSymlinks, without any problem. But if I remove the Options +FollowSymlinks line, I will get a 403 forbidden error. Does this mean my server was configured with FollowSymLinks disabled?

No, it might mean that in order to avoid the 403-Forbidden error, it is necessary to execute one of your RewriteRules. If neither FollowSymLinks nor SymLinksIfOwnerMatch is enabled, then mod_rewrite is disabled, so your rule does not get executed, and the result is a request for a disallowed file or directory.

> I tried to switch these two lines, no effect. Do I still need to update all my .htaccess files?

No, if it's not broken, don't fix it! I need to remind myself occasionally of a fact about Apache that is not obvious: Directives in .htaccess are not processed in the order that they appear. They are processed in the order that their corresponding modules execute, as set by the server config. This can vary, but the order of execution of some common modules is usually:

mod_setenv
mod_headers
mod_expires
mod_auth
mod_access
mod_rewrite
mod_alias
mod_actions
mod_dir
mod_include
mod_mime

And it appears that core Apache directives (such as 'Options') execute first of all.

Each of these modules takes its turn going through your .htaccess file and executing the directives that it understands. So the order of directives in .htaccess cannot be used to control anything other than the order of execution *among directives processed by the same module*.

Jim

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