0

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.

Remi Guan
  • 21,506
  • 17
  • 64
  • 87
Ramesh Kumar
  • 542
  • 2
  • 10
  • 19

2 Answers2

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

Community
  • 1
  • 1
Prakash Thapa
  • 1,285
  • 14
  • 27
  • If you did not change anything index.php Above step 1, 2 and 3 will work without any problem. redirect where? I don't think you have to change anything in VirtualHost – Prakash Thapa Oct 21 '15 at 11:36
  • If i enter http://www.example.com/index.php/category.html then it should redirect to http://www.example.com/category.html – Ramesh Kumar Oct 21 '15 at 11:37
1

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

Rock
  • 48
  • 1
  • 5