skip to Main Content

Canonical URL’s for Magento: Currently website has multiple url for one page.

Need to redirect below given url using 301 redirection, example:

http://www.example.com/index.php/
http://www.example.com/
http://example.com/index.php/
http://example.com/

to

http://www.example.com/

Need it for SEO purpose, Otherwise Search Engine is treating each page as duplicate.

2

Answers


  1. You can follow following steps

    • Enable apache mode_rewrite
    • http://www.example.com/ in system->configuration->General -> Web -> unsecure and secure
    • Enable search Engine optimization in System -> Configuration -> Web -> Search Engines Optimizations, select YES
    • check if RewriteBase / in .htaccess. if DOCUMENT_ROOT is another directory than RewriteBase /MAGENTO_DIR/

    Alternatively, you can also redirect to virtual host

    <VirtualHost *:80>
        ServerName example.com
        Redirect permanent / http://www.example.com/
    </VirtualHost>
    

    This apache redirect from non www to www might be helpful for you

    Login or Signup to reply.
  2. Please follow the steps

    • http://www.example.com/ in system->configuration->General -> Web -> unsecure and secure
    • Enable search Engine optimization in System -> Configuration -> Web -> Search Engines Optimizations, select YES

    Now, add below code in .htaccess file to remove index.php from url

    RewriteBase /
    RewriteCond %{THE_REQUEST} ^GET.*index.php [NC]
    RewriteRule (.*?)index.php/*(.*) /$1$2 [R=301,NE,L]
    

    Now add below code in .htaccess file to always redirect to http://www

    RewriteCond %{HTTP_HOST} !^$
    RewriteCond %{HTTP_HOST} !^www. [NC]
    RewriteCond %{HTTPS}s ^on(s)|
    RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
    

    Thanks

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search