Magento – Remove /index.php from the Magento URL gives 404 error

404-pagemagento-1.7url

I am using Magento ver. 1.7.0.2.

Here it is the link to my website: http://dev.blokeundees.com.au/

I have to remove the /index.php folder from URLs so I edited the .htaccess file and backend too (secure, web server rewrites) and /index.php has been properly removed.

But when accessing the frontend, it returns a 404 error (Page not found) for every page except the index page.

I don't know why this is happening.

Best Answer

How to Remove index.php from Magento URLs

Magento is a fantastic platform for selling online, arguably the best, but there’s one thing that has always left me frustrated as an SEO… That pesky index.php directory in the URL of ALL internal pages – nightmare!

There’s no benefit to them.

They’re bad for SEO, bad for site structure and consistency, and then they’re even worse for a clean URL freak like me. They’re not sexy enough. Let’s clean things up.

SEO Friendly Magento URLs in Two Steps

Fortunately, whilst I was doing a Magento store for a client recently, I did a little bit of digging and found a pretty straightforward solution to the issue. It involves a couple of changes to the Magento admin settings and the addition, or modification, of a simple .htaccess file to sort out of the rewriting of their standard store URLs.

Follow the simple steps below and you’ll be a step closer to SEO success with your own Magento store, and your SEO won’t have an excuse for decreased relevancy.

1) Let’s Change a Setting, Admin

The first thing you need to do is to login to your Magento admin panel (index.php/admin) in order to change a very simple setting which will let Magento know that you intend to use URL rewriting throughout your store rather than their ugly default URLs.

Login, and change this setting:

Go to System > Configuration > Web > Search Engine Optimization

Use Web Server Rewrites: YES

That was easy, wasn’t it? Okay, now for the final step.

2) Let’s Use a .htaccess File to Rewrite the URLs

The final step involves creating a .htaccess file in the Magento installation folder in order to compliment the settings you changed within your admin settings earlier, and this will actually rewrite the URLs. Choose the applicable .htaccess version below.

If your Magento store is installed in root (public_html), use this:

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

If your Magento store is installed in a subfolder (public_html/shop), use this:

RewriteEngine On
RewriteBase /shop/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /shop/index.php [L]

You’re done – hope that helps!

It’ll definitely stop your SEO from pulling out his or her hair.

Let me know in the comments below if you use this or run into any issues!

Related Topic