Welcome to WebmasterWorld Guest from 54.211.136.250

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

301 Redirect: [R=301,L] or [R=permanent,L]

Which one is correct?

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

10+ Year Member



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?

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

10+ Year Member



Sorry, I forget to search Apach DOC. You may find the answer here:
[httpd.apache.org...]
(Search 'permanent')
5:04 am on Apr 18, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



301 and permanent are the same thing.
5:08 am on Apr 18, 2004 (gmt 0)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member



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

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

10+ Year Member



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?
3:06 pm on Apr 21, 2004 (gmt 0)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member



> 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