Archived Blogs and Articles

mod rewrite and .htaccess in magento  E-mail
Written by Administrator   
Thursday, 18 June 2009 16:51
I have the exact same issue on how to remove index.php from the url. Here are the steps: 1. I first enabled the rewrite in Admin>System>Configuration>Web>Search Engine Optimization>Use Web Server Rewrites 2. I also enabled mod_rewrite in apache2 in the terminal with: sudo a2enmod rewrite and then restart apache2 with sudo /etc/init.d/apache2 restart I checked that mod_rewrite is enabled in the directory: /etc/apache2/mods-enabled/rewrite.load At this point, I can properly display the homepage without the index.php in the home url. All is well until I click on any product category or any link, the index.php in the url is removed but I receive a 404 error. If I manually type in the index.php in the address bar, I can navigate to the page. After searching the forum on this problem, people having the same problem resolved it with .htaccess. Here’s what I did: 3. I copied the content of .htaccess.sample in the magento root and paste it to a new file called .htaccess in the same directory. 4. I uncommented the statement: “RewriteBase /magento/” and change it to “RewriteBase /” since my magento directory is already the root This didn’t resolve the problem, I still have the 404 error. I search the forum again, and tried: 5. I issued the command in terminal to edit http.conf: sudo gedit /etc/apache2/httpd.conf and paste the following in the file # Each directory to which Apache has access can be configured with respect # to which services and features are allowed and/or disabled in that # directory (and its subdirectories). # # First, we configure the “default” to be a very restrictive set of # features. # Options FollowSymLinks AllowOverride All After restarting apache2, I’m still having the same 404 error. Another search in the forum and 6. I refreshed the catalog cache in Admin>Cache Management>Catalog Rewrites>Refresh But I still have the same 404 error when I clicked on the category page or any other links in the homepage. What could be the problem and how do I fix this? Thanks.