Removing Ugly index.php from URL with Magento Commerce
Apr 15
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!

Do not change AllowOverride All to AllowOverride None …
dpl, can you clarify? Then what should the AllowOverride be set to? I couldn’t get it to work without AllowOverride set to All.
thank you,
it worked for me. and in my apache config file it was already there. so i just need to follow 1st step.
Glad to hear it!
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
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.
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.
Hi,
Thanks for this thread. I applied it and it also work for me. many thanks.
No problem. Glad to know you got rid of the ugly index.php in your Magento install!
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.
but what can I do if I use lighttpd not apache in my server?
still need mod_rewrite enabled? and how?
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 /
this worked for me perfectly – thank you
Thanks. It work for me.
good tip and works for me, btw: I searched the title magento index.php and you are the top one result, congratulations and keep going on!
Yu Yang, it’s always interesting to see what terms you end up ranking well for. I would have never thought that “magento index.php” would be one of them! Glad this helped.
Found this at this site… and it worked for me.
http://www.bestdesigns.co.in/blog/remove-index-php-url-magento
How to remove index.php from url in magento
Ans :
If you want to access your magento URL without index.php
for example:
http://domain.com/index.php/category
to
http://domain.com/category
then use the following steps
1) Login to admin section by using the URL
http://domain.com/index.php/admin
2) then go to “System >> Configuration >>Web >> Search Engines Optimization”
Use Web Server Rewrites : YES
3) Go to “System >> Configuration >>Web >>Secure”
Use secure URL Frontend: YES
4)Then create the .htaccess file under your the magento installed folder.
If the magento installed under document root ( /home/username/public_html) then add follogig rules into .htaccess file
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
and If the magento installed under /shop or directory then add the following rules into ” /home/username/public_html/shop/.htaccess ” file.
RewriteEngine On
RewriteBase /shop/
RewriteRule ^index\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /shop/index.php [L]
Done
Hi,
Thanks for this write-up. It almost worked for me. The only difference for me, from what you’ve written, is that instead of setting “AllowOverride All” in
/etc/apache2/sites-available/default I had to go to /etc/apache2/sites-enabled/000-magento-1.5 . This file corresponds to my magento web application on that machine.
Thanks again,
urig
Uri, no problem. I’m glad to hear I got you part of the way there.
Hi great.
I have tested and ork.Below i will use this in magento 1.5 to hide index.php
first go to admin-?configuration->web->Search Engine optimization and then set
Use Web Server Rewrites to “yes”.
also
- From Magento’s admin go to System > Configuration > Web and change “Use Web Server Rewrites” to Yes
and at last in .htaccess of your root directory.
############################################
## 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 /
and refresh the cache.
Thats it.
Hi,
I tried the above but my cart page has gone total haywire. The formatting of the page is not longer as per the css. Please let me know what to do?
Thanks,
Gaurav
Hi
I have installed Magento 1.5.1.0 on Fedora and the issue now is the admin panel opens as
http://www.domain.com/index.php
This disable the install of extensions.
How to I get this issue resolved
Thanks
Nick
Hi, I have tested and the magento store is working fine, with the rewrite rules, when I click on the non secure pages.
But when the url turnes into a secure page ( https://www.mysite.com), using a ssl certificate, it throws a 404 error. I suppose I must also configure apache to rewrite stuff that goes through the door 443, does anyone know how to do that? Thanks!
It works for me.
allow override none to all is very important.
there is something similar in the book
“practical web 2.0 application with php(Zend)”
Hi,
THANKS! The AllowOverride All was the directive I needed too. I’d been going mad over this for days. It would be nice if this were in the install guide.
10/10 for blogging this!
Thanks again.
Hi,
As a rule we have our site running without /index.php at the end which is great, but after looking at Google Analytics, we appear to be getting urls like this:
http://www.store.com/index.php/section/index.php or
http://www.store.com/index.php/cms-page/index.php
Not all the time, just every now and again in the Analytics…
These pages do not work, so I am questioning where these pages are being generated & why?
Any help appreciated!
Thanks.
This article save my day! a new magento store now is without index.php!!
Great Article!
We have Magento 1.6 installed in a sub-directory. We’ve copied .htaccess and index.php to the root directory.
So we have 2 .htaccess files:
/.htaccess
/magento/.htaccess
The site works fine except for this index.php in the url. Does anyone have any insight on how to remove it when your installation is in a sub-directory.
Ive already verified that:
1. httpd.conf’s Allow Override = All
2. System->Config->Web->Use Web Server Rewrites = Yes
3. System->Config->Web->Use Secure URLs in Frontend = Yes
In /.htaccess — RewriteBase /magento/
In /magento/.htaccess — #RewriteBase (commented out)
Thanks!
I was setting up magento on rackspace cloud and was having index.php in url, so all my links was not working…spend hours to figure out server setting…removed magento cached after restarting apache…and frontend links works like a charm…thanks!!
any idea, why my admin not working…i am getting the admin login page, entering correct username/password..but when it redirects it takes me to the blank page..and in URL i have
index.php/admin/index/index/key/88911a8566fc884f4ba9eb08cd0766c3/
don’t know, whats the problem.