so with apache I have a folder:
www.domain.com/folder/folder1/index.php?word=blahblah
and I want users who accessed www.domain.com/folder/folder1/blahblah to be redirected to the above URL without changing the URL.
So I have the following .htaccess in folder / folder1 /, which works fine:
RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.+)$ index.php?word=$1
So, I want to achieve the same functionality with nginx, and I used two converters: http://www.anilcetin.com/convert-apache-htaccess-to-nginx/ leads to:
if (!-f $request_filename){ set $rule_0 1$rule_0; } if (!-d $request_filename){ set $rule_0 2$rule_0; } if ($rule_0 = "21"){ rewrite ^/(.+)$ /index.php?word=$1; }
and http://winginx.com/htaccess results in:
if (!-e $request_filename){ rewrite ^(.+)$ /index.php?word=$1; }
Now, I tried with both, but it doesnβt work. I tried to insert them into either
location / { }
or
location /folder/folder1 { }
or
location ~ \.php$ { }
in all places I get 404 error
nginx reports the error "primary script unknown when reading the response header from the upstream" or "there is no such file or directory."
can someone enlighten me please?
early!
source share