nginx配置中添加(修改)代码:
location / {
try_files $uri $uri/ /index.php?$args;
}
.htaccess添加:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
#RewriteRule .* index.php/$0 [PT,L]
ErrorDocument 404 index.php/error/404
两个RewriteRule似乎都可以,没做更多的测试,适用于隐藏index.php
location / {
}
.htaccess添加:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
#RewriteRule .* index.php/$0 [PT,L]
ErrorDocument 404
两个RewriteRule似乎都可以,没做更多的测试,适用于隐藏index.php
本文详细介绍了在Nginx配置中添加代码的方法,包括如何在location块中设置try_files,以及如何在.htaccess文件中实现重写规则以隐藏index.php。通过实例演示了如何优化路由和提高网站安全性。
582

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



