。
我在.htaccess
中对某些规则有疑问。
我想将所有网页放在/pages/
文件夹中,包括index.php
。
因此,这是我在.htaccess
中的规则:
#root / to pages/index.php
RewriteRule ^$ /pages/index.php [L,QSA]
# if url is /index.php redirect /
RewriteCond %{THE_REQUEST} index\.php
RewriteRule ^index\.php$ / [R=301,L]
# if url is pages/index.php redirect /
RewriteCond %{THE_REQUEST} pages/index\.php
RewriteRule ^pages/index\.php$ / [R=301,L]
# if url is pages/ redirect /
RewriteCond %{THE_REQUEST} pages/
RewriteRule ^pages/$ / [R=301,L]
但是我的问题是... index.php
..有4个规则。我有疑问,
这似乎有效,但是我们可以简化它吗?
I have a question about some rules in .htaccess
.
I want to put all my web pages in the /pages/
folder, including index.php
.
So to do this, here are my rules in .htaccess
:
#root / to pages/index.php
RewriteRule ^$ /pages/index.php [L,QSA]
# if url is /index.php redirect /
RewriteCond %{THE_REQUEST} index\.php
RewriteRule ^index\.php$ / [R=301,L]
# if url is pages/index.php redirect /
RewriteCond %{THE_REQUEST} pages/index\.php
RewriteRule ^pages/index\.php$ / [R=301,L]
# if url is pages/ redirect /
RewriteCond %{THE_REQUEST} pages/
RewriteRule ^pages/$ / [R=301,L]
But my question is... There are 4 rules for index.php
.. so are the rules good? I have small doubts
It seems to work but can we simplify it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论