很多站长朋友们都不太清楚nginx隐藏.php,今天小编就来给大家整理nginx隐藏.php,希望对各位有所帮助,具体内容如下:
本文目录一览: 1、 nginx怎么配置隐藏index.php 2、 nginx怎么隐藏index.php 3、 Nginx如何配置实现隐藏php后缀 nginx怎么配置隐藏index.phpnginx.conf里边写
location / {
if (!-e $request_filename){
rewrite ^/(.*)$ /index.php/$1 last;
}
}
nginx怎么隐藏index.php在访问 的时候、跳转到 ;
也就是开启重写功能;
在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 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的浏览目录的功能;
Nginx如何配置实现隐藏php后缀如何实现隐藏php的扩展名访问
提供一个思路: apache可以通过开启mod_rewrite然后重写一下url规则。 nginx的可以通过try_files实现
关于nginx隐藏.php的介绍到此就结束了,不知道本篇文章是否对您有帮助呢?如果你还想了解更多此类信息,记得收藏关注本站,我们会不定期更新哦。
查看更多关于nginx隐藏.php nginx隐藏ip的详细内容...