Nginx like Rewrite feature (.htaccess) doesn't seem to be working (Help)

Maxim Dounin mdounin at
Mon Feb 17 10:37:33 UTC 2014


On Sun, Feb 16, 2014 at 11:58:00AM +0000, Paulo Ferreira wrote:

> Good Morning.
> I'm making a site and I want to make the link more usable so I used the
> Apache's RewriteCond which is the one I more comfortable with. I know that
> there are a site or two that lets me convert and so I used them, the thing
> is that it doesn't seem to be working neither of them.
> this is what I have
> RewriteEngine On
> RewriteCond %(REQUEST_FILENAME) !-d
> RewriteCond %(REQUEST_FILENAME) !-f
> RewriteCond %(REQUEST_FILENAME) !-i
> RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]

First of all, original rewrite rules you are trying to convert 
seem to be invalid.  There is no "-i" test in Apache AFAIK.

You may want to rethink what you are trying to do, and do this in 
nginx - instead of trying to convert rules you think you need.


> My configuration is as follows
> My question is... Do I have to make an additional configuration to make it
> work or do I have to install something extra to make it work?

Your configuration already redirects everything which isn't on the 
file system to /index.html, using the following rule:

    location / {
        try_files $uri $uri/ /index.html;

What you likely need is to change /index.html to your php script.  

See also this article for examples:

Maxim Dounin

More information about the nginx mailing list