5

I've notice in firebug that the non-www version of my magento store redirects to the www version using 302. For SEO purposes I want it to redirect using 301.

How I tried to fix it

I went to the System > Configuration > General > Web > Url Options and my setting Redirect to Base URL if requested URL doesn't match it is set to Yes (there are only 2 options: Yes or No)Magento 1.4 URL Rewrite options

Imporantant notes

I'm using Magento v1.4.0.1 My .htaccess file contains the following, in regards to URL Rewrites:

<IfModule mod_rewrite.c>
    Options +FollowSymLinks
    RewriteEngine on
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
    RewriteCond %{REQUEST_URI} !^/(media|skin|js)/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-l
    RewriteRule .* index.php [L]
</IfModule>

How can I change the redirect method to 301?

Bogdan
  • 1,053
  • 5
  • 20
  • 41

2 Answers2

10

As of 1.6.2.0 there seems to be an option to select the redirect method in the Admin Panel, no need to modify the .htaccess.

Simply go to System -> Configuration -> Web -> Url Options and set Auto-redirect to Base URL to your preferred method.

Louis B.
  • 2,348
  • 1
  • 29
  • 51
  • the question was for magento 1.4.0.1 and there's no option in the admin pannel for that. – Bogdan May 17 '13 at 13:08
  • 2
    Absolutely, but it's also one of the first results that comes up on Google when searching for a solution to this problem, so I thought I'd amend the current solution for anybody who finds this via Google. :) – Louis B. May 17 '13 at 17:53
  • I've found this doesn't work. Using http://tools.seobook.com/server-header-checker/, www. example.com is showing as 302, but example.com (minus www.) is showing 301. – stefannew Oct 17 '14 at 15:46
4

Try changing the last line to this:

RewriteRule .* index.php [R=301,L]

See Apache mod_rewrite RewriteRule Directive the section about flags.

Fabian Barney
  • 14,219
  • 5
  • 40
  • 60