可以通过URL重写隐藏应用的入口文件index.php
(也可以是其它的入口文件,但URL重写通常只能设置一个入口文件),下面是相关服务器的配置参考:
Options +FollowSymlinks -Multiviews RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php?/$1 [QSA,PT,L]
如果你的服务器环境支持ISAPI_Rewrite
的话,可以配置httpd.ini
文件,添加下面的内容:
在IIS的高版本下面可以配置
RewriteRule (.*)$ /index\.php\?s=$1 [I]web.Config
,在中间添加rewrite
节点:
在Nginx低版本中,是不支持PATHINFO的,但是可以通过在Nginx.conf
中配置转发规则实现:
location / {
index index.htm index.html index.php;
#访问路径的文件不存在则重写URL转交给ThinkPHP处理
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php/$1 last;
break;
}
}