Magento – My .htaccess doesn’t allow backend to save changes

indexmagento-1.7redirect

I have rules in my .htaccess file that I use in order to completely eliminate index.php from all URLs in a Magento installation I have (currently in a subdomain).

    Options +FollowSymLinks
    RewriteEngine on

    RewriteBase /

    RewriteCond %{THE_REQUEST} ^.*/index.php
    RewriteRule ^(.*)index.php$ http://my.website.com/$1 [R=301,L]
    #RewriteRule ^index.php/(.*) $1 [R=301,QSA,L]

Everything works fine (almost). Whenever I type in a URL with index.php it automatically redirects to its non index.php version. The commented line (RewriteRule ^index.php/(.*) $1 [R=301,QSA,L]) is the one that's giving me trouble. When uncommented, I can't save any changes in the backend (Ex: Changing the store name or a product name, etc…)

What am I doing wrong?

Best Answer

Thanks for your help. I figured it out. To backtrack, I believe the options in Magento remove index.php visually, however the website still responds to it, if I were to type in www.mysite.com/index.php for example the home page will still load. I never want to see index.php anywhere, so I'd like to redirect any URLs with index.php to it's non index.php version. So I've come up with the following:

RewriteRule ^(.*)(index.php/admin)($|/) - [L]
RewriteCond %{THE_REQUEST} ^.*/index.php
RewriteRule ^(.*)index.php$ http://www.mysite.com/$1 [R=301,L]
RewriteRule ^index.php/(.*) $1 [R=301,QSA,L]

The issue I was having was that I was also redirecting index.php URLs in the backend, therefore no changes were being saved. The first line above ommits the admin (backend) from redirects and all URLs with index.php redirect (301) to its non index.php version correctly.

Related Topic