简体   繁体   中英

htaccess rewrite rule for magento index.php single home URL?

Magento by default listens to 3 possible url's for reaching the home page:

  1. https://www.shop.nl/
  2. https://www.shop.nl/index.php
  3. https://www.shop.nl/index.php/

Google doesn't like this behaviour, and i'm trying to optimize my shop for search engines. So i went to the .htaccess file of Magento and tried to edit the correct rules. However this does not seem to work.

I tried replacing line 175: RewriteRule .* index.php [L] with:

RewriteCond %{REQUEST_URI} !^/index.php/admin($|/)
RewriteRule ^index.php(/(.*))? /$2 [R=301,QSA,L]

This because it occured to me that magento's back-end doesn't like that i'm removing the index.php from the URL. It works for the root URL. But the problem is i can't view any other pages. All redirect me to the home page.

Does anybody have any suggestions? And i also would like to find out why magento is doing this at all. I can't figure out how this could be usefull.

Notice: I wonderd if it matters that i am running on suPHP .

Add this rule as first rule in your magento .htaccess:

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

This will remove index.php from original URL (not from the rewritten URI).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM