Magento: After “Use Web Server Rewrite” is set to yes, home page loads but other pages give 404 error.

To remove index.php from the Urls in Magento, I enabled web server rewrites from Magento admin. I cleared the Magento cache and refreshed the home page. The home page loaded well and index.php was removed from all the links on home page but when I clicked link on any home page it gave me 404 error.  If I added index.php to the page URL in browser manually it loaded well. I had Apache running on Ubuntu.

I followed the following steps to enable web server rewrites from Magento admin were:

1. Login to Magento admin
2. Go to Admin >> System >> Configuration
3. Under “General tab”, click on “Web” section
4. Expand “Search Engines Optimization”
5. Select “Yes” in dropdown for “Use Web Server Rewrites”
6. Save the configuation
7. Clear the Magento Caches.

To troubleshoot the issue I verified that Apache module “mod_rewrite” was enabled by running the following command in Ubuntu.


apache2ctl -M

Then I verified that .htaccess file was present in the Magento root folder. I verified its setting and also checked the “RewriteBase” path, it was correctly set as:


RewriteBase /magentodemo/

I had Magento installed in /var/www/magentodemo folder.

Finally I found the issue. I had the .htaccess file present in Magento root folder but it was being ignored by Apache.

The issue was that “AllowOverride” directive was  set to “None” for the DocumentRoot in Apache configuration file as below:


<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>

To resolve the issue I set the “AllowOverride” directive to “All” as below:


<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>

After saving the Apache configuration file and restarting the server, the links started working.

Comments

Leave a Comment

Back to top