Removing Ugly index.php from URL with Magento Commerce



If you’re working with Magento Commerce you’ll most likely want to remove index.php from the URL when you go live. Or maybe you don’t care so feel free to stop reading.

This post addresses all the things you can do to remove index.php, but let me touch on the items that worked for me:

- From Magento’s admin go to System > Configuration > Web and change “Use Web Server Rewrites” to Yes

- Make sure both Base URLs for secure and unsecure don’t contain index.php

- Make sure Apache rewrites are enabled: sudo a2enmod rewrite

- This is the big one…I had to change my Apache config (/etc/apache2/sites-available/default) where it references AllowOverride None to AllowOverride All

- Restart Apache and you should be good to go

I hope this helps!



12 Responses to “Removing Ugly index.php from URL with Magento Commerce”

  1. dpl says:

    Do not change AllowOverride All to AllowOverride None …

  2. dennis says:

    dpl, can you clarify? Then what should the AllowOverride be set to? I couldn’t get it to work without AllowOverride set to All.

  3. D says:

    thank you,
    it worked for me. and in my apache config file it was already there. so i just need to follow 1st step.

  4. dennis says:

    Glad to hear it!

  5. Shahid says:

    From Magento’s admin I went to System > Configuration > Web and change “Use Web Server Rewrites” to Yes and also rewrites are enabled in apache. AllowOverride is set to ALL as well but still on front-end it is giving me 404 error. I don’t know why can somebody plz help…

    Thanks a lot in advance

  6. dennis says:

    Have you verified that the Magento .htaccess file exists in the web root? That has caught me a couple times because depending on your OS the .htaccess file won’t show in your FTP client.

  7. Shahid says:

    Thank dennis for your response. I have checked and the .htaccess file exist in my root folder. By the way I have subfolder instead of root.

    Looking forward for your response.

  8. Hi,

    Thanks for this thread. I applied it and it also work for me. many thanks.

  9. dennis says:

    No problem. Glad to know you got rid of the ugly index.php in your Magento install!

  10. Marco says:

    Nice thread. However using “Web Server Rewrites” and changing it to Yes does the trick.

    Changing .htaccess file may not be the best idea.

    However that depends on several versions of magento.

  11. bruce says:

    but what can I do if I use lighttpd not apache in my server?
    still need mod_rewrite enabled? and how?

  12. John says:

    Another way to remove index.php in magento store url as below:

    Change your .htaccess file in

    ############################################
    ## you can put here your magento root folder
    ## path relative to web root
    #RewriteBase /magento/

    I deleted # and magento/
    So my new row looks like

    RewriteBase /

Leave a Reply