2

I recently setup a magento store and the URL is mydomain.com/index.php/admin or mydomain.com/index.php/about-us. I'd like to remove the index.php and I googled methods on how to and I found this code should work, but it does not:

<IfModule mod_rewrite.c>

############################################
## enable rewrites

    Options +FollowSymLinks
    RewriteEngine on

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

    RewriteBase /

############################################
## workaround for HTTP authorization
## in CGI environment

    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

############################################
## always send 404 on missing files in these folders

    RewriteCond %{REQUEST_URI} !^/(media|skin|js)/

############################################
## never rewrite for existing files, directories and links

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-l

############################################
## rewrite everything else to index.php

    RewriteRule .* index.php [L]

</IfModule>

Thanks.

4 Answers 4

1

What you have to make sure first, is that, in Apache, (If that's what you are using) to enable Mod Rewrites ... THEN you can add the following to your .htaccess file.

To enable Mod Rewrites:

sudo a2enmod

From SSH command line (or talk to your host)

.htaccess:

RewriteEngine on
RewriteRule .* index.php [L]
Sign up to request clarification or add additional context in comments.

3 Comments

So you are saying the code I posted above already made to remove the index.php URLs? I have mod_rewrite enabled.
That is what I am saying .. Yes --> Are you using RewriteEngine on as well? This is required.
Is the .htaccess file in the "root" directory? (Residing in the same directory as Magento app)?? If so .. You can remove this line: RewriteBase /. That is if, say you have /var/www <-- Where your .htaccess resides, and Magento resides in /var/www/magento for example. If that's not the case, then remove that line. If that IS the case, then you need to edit that line and it should look like RewriteBase /magento.
1

You really should use the second method and let Magento force the rewrite rule. Its the cleanest way. It will do exactly that, remove index.php from the url in all cases.

1 Comment

Try backing up that file (php.ini right?) and then cut out all rewrite rules. Then try enabling it from Magentos backend, or replace the php.ini with an original php.ini file for default magento installs.
1

Looks like you have given wrong relative path of your Magento root folder:

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

RewriteBase /

Comments

0

Go to Magento Back end.

Navigate to System > Configuration then Web in left hand side sidebar.

Now chose Use Web Server Rewrites to Yes

Clear the Cache.

Done

Comments

Your Answer

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.