nginx隐藏index.php的设置方法-PHP问题

资源魔 41 0

nginx暗藏index.php的办法:起首找到并关上“nginx.conf”设置装备摆设文件;而后增加语句“rewrite ^/(.*)$ /index.php/$1 last;”;最初保留该文件便可。

nginx暗藏index.php的设置办法

正在拜访 http://php.cc/Att/AttList 的时分、跳转到http://php.cc/index.php/Att/AttList ;

也就是开启重写性能;

正在nginx设置装备摆设文件nginx.conf中增加:

location / {
if ( !e $request_filename ) {
rewrite ^/(.*)$ /index.php/$1 last;
}
}

假如名目入口文件是正在一个子目次外面,则以下:

location / {
if ( !e $request_filename ) {
rewrite ^/目次/(.*)$ /目次/index.php/$1 last;
}
}

切记:不成以呈现两个location / {}、不然nginx效劳器将启动没有了;

我的设置装备摆设文件以下:

server {
listen 80;
server_name www.abcphp.cc abcphp.cc;
root "D:/abc/php";
location / {
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php?$1 last;
}
index index.html index.htm index.php;
autoindex on;
}
location ~ \.php(.*)$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
include fastcgi_params;
}
}

此中:

autoindex on; 是关上nginx的阅读目次的性能;

更多相干常识,请拜访PHP中文网!

以上就是nginx暗藏index.php的设置办法的具体内容,更多请存眷资源魔其它相干文章!

标签: php教程 nginx php故障解决 php使用问题 index.php

抱歉,评论功能暂时关闭!