【注】必备条件
开启伪静态 (url路由)
Nginx:
在 server { } 大括号里面添加下面的代码:
location / {
if (-f $request_filename/index.html){
rewrite (.) $1/index.html break;
}
if (-f $request_filename/index.php){
rewrite (.) $1/index.php;
}
if (!-f $request_filename){
rewrite (.*) /index.php;
}
}
然后重新启动 nginx: service nginx restart
Apache:
vim /etc/httpd/conf/httpd.conf
Options FollowSymLinks ExecCGI Indexes
AllowOverride all
Order deny,allow
Allow from all
Satisfy all
NameVirtualHost *:80
Apache .htaccess
如果Appache 支持 .htaccess,那么可以编辑 .htaccess 文件放置于根目录下:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
#RewriteRule ^(.)$ index.php [L,E=PATH_INFO:$1]
#RewriteRule ^(.)$ index.php?/$1 [L]
RewriteRule ^(.*)$ index.php [L,QSA]
联系
Email:edikud(at)163.com QQ群:464430963