Welcome to WebmasterWorld Guest from 54.196.145.173

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)

Full Member

10+ Year Member

joined:Jan 19, 2003
posts:324
votes: 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?

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

Full Member

10+ Year Member

joined:Jan 19, 2003
posts:324
votes: 0


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)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:July 1, 2002
posts:1424
votes: 0


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

Senior Member

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

joined:Mar 31, 2002
posts:25430
votes: 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

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

Full Member

10+ Year Member

joined:Jan 19, 2003
posts:324
votes: 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?
3:06 pm on Apr 21, 2004 (gmt 0)

Senior Member

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

joined:Mar 31, 2002
posts:25430
votes: 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

 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members