DirectoryIndex 未分配新的默认目录
我刚刚将完全静态的 HTML 网站 更改为 PHP 网站,以便于编辑。我在 .htaccess 文件中使用了 301 RedirectMatch,因此将所有 .html 页面定向到新的 .php 页面。然而,当我这样做时,它决定将我的默认目录从index.php(已经有一段时间是php)更改为default.php。我什至没有名为default.php 的文件。无论如何,我尝试将 DirectoryIndex 行添加到我的 .htaccess 中以将其更改回 index.php,但它仍然对 default.php 执行此操作。
这是我的 .htaccess:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
RedirectMatch 301 (.*)\.html$ http://www.fifaencyclopedia.com$1.php
DirectoryIndex index.php
我做错了什么?我该如何解决这个问题?
编辑:我刚刚制作了一个default.php页面,所以那里有一些东西,但我宁愿它是index.php。
编辑:GerManson,将其移至顶部不起作用:(
I just got finished changing my entirely static HTML website into a PHP one to allow editing ease. I used a 301 RedirectMatch in my .htaccess file so direct all the .html pages to the new .php ones. However, when I did this, it decided to change my default directory from index.php (was already php for a while) to default.php. I don't even have a file named default.php. Anyways, I tried to add a DirectoryIndex line into my .htaccess to change it back to index.php, but it's still doing to default.php.
Here's my .htaccess:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
RedirectMatch 301 (.*)\.html$ http://www.fifaencyclopedia.com$1.php
DirectoryIndex index.php
What am I doing wrong? How do I fix this?
EDIT: I just made a default.php page so there's something there, but I'd rather it be index.php.
EDIT: GerManson, moving it to the top did not work :(
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
重定向是否正常工作?
您可能需要在虚拟主机配置上设置
AllowOverride All
。如果它是共享主机,则可能会出现重定向在
DirectoryIndex
指令之前起作用的情况。只需将其移至顶部即可are the redirections working propertly?
you may need to set
AllowOverride All
on your virtual host configuration.if its is a shared hosting, it may be the case that the redirections are working before the
DirectoryIndex
directive. just move it to the top