1

I need to remove index.php from Magento website url. I have checked https://stackoverflow.com/questions/10474740/how-to-remove-index-php-from-urls. I have followed the same instruction and successfully remove index.php from the url on localhost.

But while on server it is not working. url redirect is working properly but it is showing 404 not found error message. I have alse set up .htaccess file as given in the instruction but it is not working.

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

In my server all file and folder owner is root. Any kind of suggestion would help.

  • If your server runs on nGinx, the .htaccess file will not work. – Greg Dec 13 '17 at 15:07
2

What is the web server you are using ? Apache or nGinx ?

Updated Answer

Since you are using Apache, make sure that you have enabled mod_rewrite in your server. To enable mod_rewrite, follow the steps in this page https://www.digitalocean.com/community/tutorials/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-16-04

The above page includes instructions to enable the use of .htaccess file also. That needs to be done too.

Do not use your own .htaccess file. Instead use the one provided by Magento out-of-the box.

Updated Answer - 2

Have you verified that under System -> Configuration -> Web -> Search Engine Optimization -> Use web server rewrites is set to Yes ?

Updated Answer - 3

To remove index.php from home page URL, you need to write rules in .htaccess file only. This is why I asked you to use the .htaccess file provided by Magento. That will do all these things out-of-the-box.

Updated Answer - 4

Add this rule to your .htaccess file

RewriteCond %{THE_REQUEST} ^.*/index.php
RewriteRule ^(.*)index.php$ http://www.yourdomain.com/$1 [R=301,L]
redirect 301 /home http://www.yourdomain.com
  • I am using Apache web server with ubuntu 16.04 – Suvojit Mondal Dec 13 '17 at 15:15
  • @SuvojitMondal I have updated the answer – N. Karthic Kannan Dec 13 '17 at 15:30
  • mod_rewrite is already enabled and same htaccess is working properly on localhost and my server is using ubuntu 14.04 and not 16.04. I have also tried to create a conf file inside conf-available. Can you please guide me how can write configuration directly to mods-available folder? any way of making url rewriting is fine. – Suvojit Mondal Dec 13 '17 at 17:22
  • @SuvojitMondal I have updated the answer – N. Karthic Kannan Dec 14 '17 at 6:01
  • Now its working properly for all other url but for home page accessible through 3 url base_url, base_url/index.php, and base_url/index.php/. How can I make it so that website will be accessible only through base_url? – Suvojit Mondal Dec 14 '17 at 9:04

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.