1

I've been trying to remove "index.php" from the URLs. I can get it to not display index.php if I set Use Web Server Rewrites to yes in Administration but then my other store view (Spanish) all have 404 error. The closes thing I found was here: http://www.magentocommerce.com/boards/viewthread/7931/P15/#t251897 but not much success.

It seems it would be a simple rewrite. But I'm beginning to think it's not possible with NginX.

2 Answers 2

3

Have you tried to redirect the requests to the index.php bootstrap using something like this:

location / {
    try_files $uri $uri/ /index.php?$query_string;
}

You need to add this to your vhost file and restart nginx for it to work

Sign up to request clarification or add additional context in comments.

4 Comments

I've tried several different configurations. I don't have vhost set up. Everytime I set up a vhost I get strange behavior, mostly my links like category, just basically all links, download the page instead of going to the page. When I open the page that was downloaded it says, "Whoops, it looks like you have an invalid PHP version." Which is incorrect. But yes, I have this code you posted at the bottom of my config file.
This has to go inside your server directive (normally located inside a vhost file). If you already have a location / block you will need to replace it with the one I posted. After doing so you need to restart nginx.
I have 15 location blocks. They are all inside the server block. I'm going to try it at all locations and see if works. I took it off the bottom as that I couldn't see any difference anyway.
I'm getting mostly 403 Forbidden with this. My logs says, *1 directory index of "C:/mba/www/" is forbidden, client: 127.0.0.1, server: , request: "GET / HTTP/1.1", host: "www.mysite.com" But if I add the index.php to it it's ok. I think the problem is that it's not a query_string. It doesn't have a "?" just a /index.php/.../ It's not suppose to be like that as that's not the ending of the URL. It's like it has two endings. I might have to go back to Apache, at lest it American haha Just joking. I've wasted a month on this.
3

The best way is to do it with Apache or Nginx would be via vhost configuration. You don't have to change Magento codebase for this.

If you are using Apache, usually this is part of Magento's .htaccess or copy the following code in VHost config

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

If you are using Nginx, make sure to add this to your vhost configuration:

location / {
    try_files $uri $uri/ /index.php?$query_string;
} 

After changing these you need to reload configuration of respective server.

Beside this you need to turn on:

Magento Admin > System > Config > General > Web 
    > Search Engines Optimization > Use Web Server Rewrites > YES

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.