PHP隐藏入口脚本文件index.php
一、nginx下
隐藏入口文件时,配置nginx 首先得开启nginx pathinfo模式:
location ~ \.php { #去掉$
root E:/phpStudy/WWW/tp/public/;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
请求指定路径时重写URL 下面是项目路径
location /server/admin/web/ {
if (!-e $request_filename) {
rewrite ^/server/admin/web/(.*)$ /server/admin/web/index.php/$1;
}
}
二、Apache
Windows下一般都开区开启了apache重写模块。没有的话就改下httpd.conf文件。
index.php同级,建立.htaccess文件
内容如下
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]