Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Magento redirects to base url using 302, how do I get it to use 301

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?

like image 952
Bogdan Avatar asked Sep 07 '12 11:09

Bogdan


People also ask

What is a Magento 301 redirect?

What's a Magento 301 redirect? In essence, Magento 301 redirect is a way to forward bots and web visitors to the new URL. At the same time, the indexes of the old URL’s address will be deleted, and its link equity will be passed to the newly redirected page.

How to change a Magento 2 website’s URL without 404 error?

Besides, we will go through steps by steps how to properly change a Magento 2 website’s URL (without 404 error on admin or any pages). Go to your Magento 2 backend: Stores > Settings > Configuration. On the left menu, under General section, you click Web. Expand Base URLs section. Enter the unsecure (http) Base URL for your Magento website.

How do I enable https in Magento 2?

In your Magento 2 backend, move to Stores > Settings > Configuration. At the left menu, under General section, click Web. Expand Base URLs (Secure) section. To use a secure (https) for the storefront, enter the Secure Base URL, followed by a forward slash (“/”).

What is Seo redirect in Magento 2?

In fact, SEO Redirect is a minor feature of Mageplaza’s SEO solution for Magento 2 stores. Along with its ability to manage and handle 301 and 302 redirects, this module comes with a wide range of other outstanding features focusing on improving SEO performance. The bottom line!


2 Answers

Try changing the last line to this:

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

See Apache mod_rewrite RewriteRule Directive the section about flags.

like image 43
Fabian Barney Avatar answered Nov 02 '22 11:11

Fabian Barney


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.

like image 81
Louis B. Avatar answered Nov 02 '22 10:11

Louis B.