繁体   English   中英

我在使用Index.php加载主页时获得404,但index.php适用于直接链接,为什么?

[英]i get a 404 while loading the homepage with Index.php, but index.php works on direct links, why?

我似乎无法理解为什么我的Homepage突然拒绝直接加载ie: www.mysite.com/但只有在您键入www.mysite.com/index.php才会加载

这是网站:

比较

http://www.propasiarealty.com // Sends you to the 404 page

鉴于

http://www.propasiarealty.com/index.php // Loads the homepage.

无法弄清楚到底出了什么问题,请帮忙。

Bellow是一个Filezilla截图:

在此输入图像描述

编辑01

请看我的HTACCESS ...快照 在此输入图像描述


UPDATE 02我修改了HTACCESS仍然没有成功,现在看起来像:

DirectoryIndex index.php

#ErrorDocument 400     /400.html

#ErrorDocument 401     /401.html 

ErrorDocument 403     /errs/404.php

ErrorDocument 404     /errs/404.php

#ErrorDocument 500     /500.html

Options -Indexes

但仍然没有工作


更新03 [这工作]

@HPierce建议的解决方案是将HTACCESS修改为类似下面的内容:

DirectoryIndex index.php


RewriteEngine on  

RewriteRule ^$ index.php

    #ErrorDocument 400     /400.html

    #ErrorDocument 401     /401.html 

    ErrorDocument 403     /errs/404.php

    ErrorDocument 404     /errs/404.php

    #ErrorDocument 500     /500.html

    Options -Indexes

在.htaccess文件中为DirectoryIndex添加新声明。

DirectoryIndex index.php

对于Apache,默认的DirectoryIndex将设置为index.html ,它与您要提供的index.php页面不同。

或者,您可能希望将这两个文件指定为DirectoryIndex

DirectoryIndex index.html index.php

如果index.html不可用,这将首先检查index.html然后检查index.php 这可能是更好的解决方案,因为更改默认值可能会混淆必须在您的网站上工作的任何其他人。

mod_dir上的Apache文档: http ://httpd.apache.org/docs/2.4/mod/mod_dir.html

如果这不起作用,您可以考虑添加重写规则 - 尽管不建议这样做。 重写规则会中断传入的HTTP请求并对其进行重新调整以匹配服务器的设置方式。

RewriteEngine on 
RewriteRule ^$ index.php

此重写规则仅匹配 http://www.propasiarealty.com/请求,与http://www.propasiarealty.com 不匹配

使用重写规则需要安装mod_rewrite - 更多信息请访问http://httpd.apache.org/docs/current/mod/mod_rewrite.html

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM