Magento URLs other than home page do not work without index.php

48,163

Solution 1

Did you try:

RewriteBase /magento/

and not RewriteBase /mymagento/ because your url is http:// localhost/magento/

Does your apache virtual host allow to overwrite the config, e.g.

<VirtualHost *:80>
...
<Directory /var/www/magento/>
    AllowOverride All
</Directory>
</VirtualHost>

Solution 2

Do you have the appropriate .htaccess file in your Magento root? Also, you may run into issues with localhost. It's advised to use 127.0.0.1 or to map dev domains in your hosts file.

Solution 3

Go to admin url of your site. 
Suppose,http://example.com/index.php/admin/

Go to 'System' menu from navigation and click on 'Configuration'.
Under the 'General' tab in the left, click on 'Web'.
Open the 'Search Engines Optimization' section by clicking on it.
Then set 'Use Web Server Rewrites' value to 'No'

Solution 4

Within the Magento configuration (accessed in the Magento Admin Panel through System > Configuration) there are some relevant settings that determine what the eventual Search Engine Friendly URL looks like.

Web > Search Engine Optimization > Use Web Server Rewrites

A setting which should always be turned on. If not "/index.php/" will be added to URL which is unnecessary and looks ugly. To enable this option, you also need Apache mod_rewrite enabled in your hosting environment.

Catalog > Search Engine Optimizations > Product URL Suffix

The default value here is ".html" which will be appended to each product URL. Some SEO-experts claim this is needed for better rating, other SEO-exports say it is not. For our MageBridge integration with Joomla! this setting needs to be empty.

Catalog > Search Engine Optimizations > Category URL Suffix

The same as above, but now categories.

Catalog > Search Engine Optimizations > Use categories path for product URLs

With this option enabled, the product URL will also include the category URL Keys. While it could be argued this causes duplicate content, product pages might also benefit from this because they become part of a bigger structure.

Catalog > Search Engine Optimizations > Use Canonical Link Meta Tag For Products

If you are really worried about duplicate content (which is not as bad as some people will tell you), then you can enable the canonical tag which tells search engines which page is leading once duplicate content has been detected.

Catalog > Search Engine Optimizations > Use Canonical Link Meta Tag For Categories

The same as above, but for categories.

further reading on the matter http://www.yireo.com/tutorials/magento/magento-administration/664-fixing-url-rewrites-with-magento

Solution 5

Enabling Apache rewrite module for wamp worked for me.

enter image description here

Share:
48,163
user1527429
Author by

user1527429

Updated on July 05, 2022

Comments

  • user1527429
    user1527429 almost 2 years

    My magento is installed on Ubuntu Linux under /var/www/magento . This question looks like some of the questions in the archives but is acutally somewhat different. When I installed Magento on Ubuntu Linux I enabled Apache mod_rewrite URL rewrites.

    When I go to http:// localhost/magento my server rewrites the URL as http:// localhost/magento/ and displays the page. I then click on one of the links in the navigation bar, let's say it's nav-bar item "foo". Then magento takes me to:

    http:// localhost/magento/foo.html

    which displays a "Not Found" apache page.

    I have to change the URL to ----->

    http:// localhost/magento/index.php/foo.html

    in order to display the page.

    It is as though something is amiss in my mod_rewrite workings.

    Thanks,

    John Goche

    CONFIGURATION: System -> Configuration -> (General ->) Web:

    Use Web Server Rewrites: YES

    Base URL: http:// localhost/magento

    If I set "User Web Server Rewrites:" to NO, then the links from my main page work fine, but see the page http:// localhost/magento/index.php/foo.html which displays the correct page, but whereas the website works I don't like the URL. I would like it to be http:// localhost/magento/foo.html without the index.php bit, as this would also probably be more SEO-friendly.

    THanks,

    John Goche


    Update: I've tried uncommenting my artificial 127.0.1.1 IP address which ubuntu had put in /etc/hosts and placing ther my real IP but no luck. I still have exactly the same problem. And the URL inside my browser is rewritten to http:// localhost / etc... whenver I type 192.168.3.31, avalanche, or avalanche.com inside it. I am still trying to figure out how to solve the problem described above as this did not do it.

    127.0.0.1       localhost
    #127.0.1.1      avalanche
    
    192.168.4.35    avalanche avalanche.com
    

    When I restart Apache I get:

    # service apache2 restart
     * Restarting web server apache2                                                apache2: Could not reliably determine the server's fully qualified domain name, using 192.168.4.35 for ServerName
     ... waiting apache2: Could not reliably determine the server's fully qualified domain name, using 192.168.4.35 for ServerName
    

    Not sure how to fix the original issue. I am testing on a local server.


    I've even tried this solution and then restarted apache2, but no luck!

    How to remove index.php from URLs?

    so placing:

    RewriteEngine On
    RewriteBase /mymagento/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L]
    

    does not work, even with RewriteBase /, it does not work.


    OK, finally I managed to solve the probkem. The file /etc/apache2/sites-enabled/000-default has the following directive set for all directories defined within this file:

     AllowOverride None
    

    For instance, for /var/www which is the default document root set on Ubuntu 12.04 LTS Linux system this file contains

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

    which as far as I understand means that .htaccess files found in this directory and all of its subdirectories will not be parsed. To fix the problem it is sufficient to set:

    AllowOverride All
    

    meaning you will be able to override the server configuration directives found in /etc/apache2/apache2.conf (or /etc/apache2/httpd.conf which is included therein).

    One of the reasons AllowOverride is set to None by default could be that it slows down the server and the other is for security reasons. This directive should be set inside a tag and the latter ones can override the former. Another reason this is not set by default is that having to parse .htaccess recursively across the site each time a file in a directory path is loaded can slow down the system and thus placing the .htaccess stuff in /etc/apache2/httpd.conf when possible is recommendable as it can cause an increase in speed.

    So place

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

    inside /etc/apache2/sites-enabled/000-default

    and run: service apache2 restart

    is the solution.

  • user1527429
    user1527429 almost 12 years
    Hello, Yes I have this file. It got installed when I unzipped the magento source. However I am still having the problem. Do I need to adjust this file and if so then how? Perhaps I need to change the RewriteRule .* index.php [L] or something?
  • user1527429
    user1527429 almost 12 years
    I've tried modifying my /etc/hosts file, but still have problems.
  • user1527429
    user1527429 almost 12 years
    Thank you for all of this information, but I am still having the same problem. Web > Search Engine Optimization > Use Web Server Rewrites is set to Yes at the Global level, and I have # a2enmod rewrite which says Module rewrite already enabled. So where is the problem? I want to get rid of /index.php/ in the URLs!
  • user1527429
    user1527429 almost 12 years
    Thanks, this was really helpful, and is indeed the sought solution.
  • Fiasco Labs
    Fiasco Labs almost 12 years
    Sounds like you need to get someone acquainted with Apache web server administration to help you troubleshoot why mod_rewrite is not functioning on your server. It really is as simple as turning on Use Web Server Rewrites once mod_rewrite is properly set up (flush cache and reindex URL Rewrite Index after changing and saving the setting). In your Magento root .htaccess and server config, you need to make sure the following are set in the proper places: RewriteEngine On, AllowOverride All, Options +FollowSymLinks and that RewriteBase is set to the proper directory.
  • Anton S
    Anton S almost 12 years
    like Fiasco Labs noted you now have to verify if mod_rewrite is properly configured and can be enabled through .htaccess
  • Sukeshini
    Sukeshini almost 10 years
    Thanks a lot and +1. The first option worked for me :)
  • theMayer
    theMayer over 9 years
    Is there any formatting or additional context you can add to this answer to make it more thorough?
  • CodeRomeos
    CodeRomeos about 8 years
    Tried almost all the solution from .htaccess to database tweaks. This one worked for me.! Thanks. +1