希望可以有人帮帮我。 意识到; 对不起,可能英文不好;)我想了好几个小时设置我的configs所以我的网站是没有PHP扩展访问,但将重定向任何要求与扩展,除了从URL删除/索引。
我来这里的每个扩展将删除,仍然得到了由PHP5-FPM解析点。
这里是我当前的代码:
server {
listen 80;
server_name example.com;
root /var/www/example.com;
index index.php;
<<unrelated Modulecode>>
rewrite ^(.*).php(.*)$ $1$2 permanent; # << forces index to be appended, so not exactly wanted
#rewrite ^/index$ / permanent; >> results in infinity loop for indexpage
# location ~ ^(.*)(?<!(index)).php(.*)$ { # << even don't know how to at least except index...gwarz regex x|
# rewrite ^(.*).php(.*)$ $1$2 permanent;
# }
location / {
try_files $uri $uri/ @phprule;
}
location ~ \.php$ {
try_files $uri $uri/ 404;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location @phprule {
rewrite ^(.*)$ $1.php last;
}
}
在注释掉部分是有些绝望改掉得到它在某种程度上工作X <
所以,我要完成的任务:
example.com/index.php => example.com/
example.com/foo.php => example.com/foo
example.com/some/path/foo.php => example.com/some/path/foo
希望你会得到的想法。