Ramesh Kumar
Ramesh Kumar

Reputation: 542

Canonical URL’s for Magento

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.

Upvotes: 0

Views: 305

Answers (2)

Rock
Rock

Reputation: 48

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

Upvotes: 1

Prakash Thapa
Prakash Thapa

Reputation: 1285

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

Upvotes: 1

Related Questions