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

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]

One gave me this (http://winginx.com/htaccess)

nginx configuration

location / {
rewrite ^(.+)$ /index.php?url=$1 break;
}

and the other gave me this (
http://www.anilcetin.com/convert-apache-htaccess-to-nginx/)
if (!-d %(REQUEST_FILENAME)){
set $rule_0 1$rule_0;
}
if (!-f %(REQUEST_FILENAME)){
set $rule_0 2$rule_0;
}
if (%(REQUEST_FILENAME) !~ “-i”){
set $rule_0 3$rule_0;
}
if ($rule_0 = “321”){
rewrite ^/(.+)$ /index.php?url=$1 last;
}

My configuration is as follows
http://pastebin.com/DrA4aAii

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?

I forgot I’m using Debian 7.3 (Wheezy) and my nginx version is still
1.2.1.
Don’t know if it’s important or not but my MySQL client is MariaDB
version
5.5.35

Thanks

Hello!

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

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
http://pastebin.com/DrA4aAii

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:

http://nginx.org/en/docs/http/converting_rewrite_rules.html


Maxim D.
http://nginx.org/

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs