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]


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM