
ThinkPHP可以去掉URL地址里面的入口文件index.php
,但是需要额外配置WEB服务器的重写规则。
正常访问:
http://serverName/index.php/module/controller/action/param/value/...
如果是Apache
环境的话,需要在入口文件的同级添加.htaccess
文件,内容如下:
<IfModule mod_rewrite.c>
Options +FollowSymlinks -Multiviews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?/$1 [QSA,PT,L]
</IfModule>
如果是Nginx
环境的话,可以在Nginx.conf
中添加:
location / {
// …..省略部分代码
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=/$1 last;
break;
}
}
分类目录