1

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?

asked Jun 11, 2013 at 14:37
7
  • 1
    When you say "doesn't allow" are you getting invalid form key errors? Commented Jun 11, 2013 at 14:57
  • Hi @philwinkle, no error message, it actually says "changes have been saved" (or something similar) but changes have actually not been saved. Commented Jun 11, 2013 at 15:40
  • 1
    I would say this is not possible, because the save is directly before the success message!? Commented Jun 11, 2013 at 16:33
  • Well it's as I say. Anyone know what could be wrong, it has something to do with the last line above. Commented Jun 11, 2013 at 17:10
  • I'll have to repost. Commented Jun 12, 2013 at 22:23

2 Answers 2

2

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.

answered Jul 14, 2013 at 22:37
1

What is this? This rule shouldn't be in your htaccess:

RewriteRule ^(.*)index.php$ http://my.website.com/1ドル [R=301,L]

I'm not sure what you're trying to accomplish here - seems like it's not well-formed, as it's logically saying:

If you see a file named index.php, which has any number of required characters before it, and that's all there is to the URI, then redirect to my.website.com and append whatever was before the index.php part to the end (even if it results in a double-slash). Oh, and this is the very last rule. Ignore whatever happens next.

I don't think that's what you want to happen. I think you're trying to avoid SEO canonicalization issues. Rather than redirecting, use the canonical link meta tag in System > Config > Catalog > SEO

In the future, don't modify your htaccess. Pull down a fresh one and re-install it from here:

http://svn.magentocommerce.com/source/branches/1.7/.htaccess

After you do that, check your httpd.conf file and ensure that AllowOverride is set to All.

To remove index.php from your URI, navigate to System > Config > Web > Search Engine Optimization and change Use Web Server Rewrites to 'yes'.

If that fails to save (doubtful) check the following:

  • Ensure the db user assigned to Magento has write access to core_config_data and catalog* tables. Or all tables, for that matter.
  • Kick off the install process again by deleting app/etc/local.xml
answered Jul 11, 2013 at 19:33
1
  • How could that rule cause a double slash if used in .htaccess? Commented Jul 12, 2013 at 5:26

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.