I want to write nginx rewrite rules for clean URLs.
Everytime the user hits;
http://domain.com/abc/12/16/abc-def-ghi
I need to execute
domain.com/abc.php?a=12&b=16&c=abc-def-ghi
Now my regex is right as per rubular:
^\/abc\/(\d+)\/(\d+)\/(\w+\S+)$
http://rubular.com/regexes/11063
and rule is
if (!-e $request_filename) {
rewrite ^\/abc\/(\d+)\/(\d+)\/(\w+\S+)$ abc.php?a=$1&b=$2&c=$3 last;
}
But it is giving "No input File specified". I cant find what the problem is?
Best Answer
"No input File specified" error is coming form php-handler. This means rewrite rule is working fine but some other line is not prefixing proper base_dir.
Try this...
Replace
rewrite ^\/abc\/(\d+)\/(\d+)\/(\w+\S+)$ abc.php?a=$1&b=$2&c=$3 last;
With
rewrite ^\/abc\/(\d+)\/(\d+)\/(\w+\S+)$ /abc.php?a=$1&b=$2&c=$3 last;
Please note
/ (slash)
beforeabc.php
in above line.Also problem can be...
location ~ \.php$ {}
block. I hope u have one for sure in your full config :-)root /var/www/exmaple.com;
in your config. If its inlocation \ {..}
block, you may need to copy it to thelocation ~ \.php$ {}
or move outsidelocation \ {..}
but insideserver {..}
block.If you can paste your nginx config here, it will be easier to debug. :-)