0

I wanted to remove /index.php from all Magento urls - I sought help online and found a solution within .hatacess file. There was no such file in the route of my Magento directory, so I created one with the following code -

        <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> 

The url's now seem to have changed to remove the /index.php but if I go to the url I get a 404 error. If I add back in the 'index.php' into the url it works.

Thank you very much.

  • Is Magento installed in the web server doc root or in a subdirectory? RewriteBase must reflect where Magento is installed, for example if in /magento/, then RewriteBase /magento/. The .htaccess file also needs to be in your web server doc root folder. – Fiasco Labs Mar 29 '15 at 22:10
  • Hi thanks for coming back to me, all magento files are in /httpdocs/ so am I right in thinking the rewrite base of / is correct? It is not stored in a magento specific folder. – YorkieMagento Mar 30 '15 at 7:38
  • Yes, if Magento is installed in the web server doc root, then RewriteBase / is correct. – Fiasco Labs Mar 30 '15 at 15:42
1

This is how I enabled the URL rewrites on my installation:

1. To enable the url rewrite, just turn on the Magento configuration in:

Admin > Configuration > General > Web > Search Engines optimization > Use Web Server Rewrites = Yes

2. Change the line RewriteBase / insite the .htacces file on the magento root directory if needed:

Basically, if you access your website through http://example.com/marketplace/ then you should have RewriteBase /marketplace/

3. Enable mod_rewrite in Apache:

Edit httpd.conf and add or uncomment this line LoadModule rewrite_module modules/mod_rewrite.so. If you are using wamp this file is in <install directory>/bin/apache/apache<version>/conf/

Refresh your Magento cache and try again.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.