how to nginx rewrite a.php,b.php,c.php to /index.php -
here rewrite code:
location / { if (!-e $request_filename){ rewrite "(*utf8)^/(.*)$" / last; } } location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param script_filename $document_root$fastcgi_script_name; include fastcgi_params; fastcgi_param php_value "open_basedir=$document_root:/tmp/:/proc/"; }
i wanna rewrite a.php,b.php,c.php /index.php.but doesn't work!but when type a.,b.c.,code above can work,i make wrong?
your current problem uri .php
processed php location block , therefore bypasses rewrite rule. use try_files
in both /
location , php location. example:
location / { try_files $uri $uri/ /index.php; } location ~ \.php$ { try_files $uri /index.php; fastcgi_pass 127.0.0.1:9000; include fastcgi_params; fastcgi_param script_filename $document_root$fastcgi_script_name; fastcgi_param php_value "open_basedir=$document_root:/tmp/:/proc/"; }
see this document more.
Comments
Post a Comment