不使用index.php时是否需要设置[DirectoryIndex]?
我的网站根访问由 htaccess 管理:它将各种别名重定向到它们自己的主文件 /en/home
对于英语 /de/home
对于德语等。以前,我使用index.php来路由和重定向所有这些,因此DirectoryIndex有这样的内容:
DirectoryIndex /index.php
但是现在,没有index.php文件,所以我评论了它
# DirectoryIndex /index.php
最好取消注释并将其设置为默认的 /en/home (有或没有 .php,因为在这种情况下?我已经设置了规则,所以浏览器中的页面在没有给出扩展名的情况下也可以工作)
DirectoryIndex /en/home
在所有上述情况下,我的网站工作正常,但我不这样做当我设置上述三个实例中的任何一个时,请看到任何更改。但是……“一定有一个最好的,不是吗?”
谢谢!
My sites root access is managed by htaccess: it redirects various aliases to their own home files /en/home
for english /de/home
for Deutsch etcettera. Previously, I used index.php to route and redirect all that, and hence the DirectoryIndex had something like this:
DirectoryIndex /index.php
Now, however, there is no index.php file, so I commented it
# DirectoryIndex /index.php
Would it be better to uncomment is and set it to the default /en/home (with or without .php because in this case? I have set up rules sohat my pages in browser also work when no extension is given)
DirectoryIndex /en/home
In all the above cases, my websites work fine and I don't see ANY change when I set either of the three instances as above. but ... "there's gotta be one best ain't it?"
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您在 .htaccess 中编写了规则,那么最好不要在您使用的任何 php 配置和路由函数中重复这些规则。通过 apache(您的 .htaccess)进行路由比通过 php 颠覆路由要快得多,尽管如果没有相当高的流量,您将无法实现收益。
If you have the rules written in .htaccess it is best not to repeat the rules in whatever php config and routing functions you are using. Routing through apache (your .htaccess) is much faster than subverting routes through php, though you will not realize the gains without a pretty high volume of traffic.