.htaccess文件
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
#RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
#RewriteRule ^(.*)$ index.php [L,E=PATH_INFO:$1]
RewriteRule ^(.*)$ index.php?s=$1 [QSA,PT,L]

nginx环境(未测试)
location / {
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=$1 last;
break;
}
}

本文介绍在Apache和Nginx环境下如何使用URL重写规则来优化网站结构,通过示例展示了.htaccess文件中RewriteEngine、RewriteCond和RewriteRule指令的用法,以及Nginx的rewrite模块配置。
1245

被折叠的 条评论
为什么被折叠?



