Reputation: 542
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
Reputation: 48
Please follow the steps
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
Reputation: 1285
You can follow following steps
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