简体   繁体   中英

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

I can't seem to understand why my Homepage has suddenly refused to load directly ie: www.mysite.com/ but loads only if you type www.mysite.com/index.php

This is the Site:

COMPARE :

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

WHEREAS :

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

Can't figure out exactly what is wrong, please help.

Bellow is a Filezilla screenshot:

在此输入图像描述

EDIT 01

Please see my HTACCESS... Snapshot 在此输入图像描述


UPDATE 02 I have modified the HTACCESS still no success, now looks like:

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

But still not Working


UPDATE 03 [This worked]

The Solution as suggested by @HPierce was to modify the HTACCESS to look something like bellow:

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

Add a new declaration for DirectoryIndex in your .htaccess file.

DirectoryIndex index.php

With Apache, the default DirectoryIndex will be set to index.html which is different than your index.php page that you want to serve.

Alternatively you might want to specify both files as your DirectoryIndex

DirectoryIndex index.html index.php

This would check for index.html first then index.php if index.html is not available. This might be the better solution, as changing the defaults may confuse anyone else that has to work on your website.

Apache docs on mod_dir: http://httpd.apache.org/docs/2.4/mod/mod_dir.html

If that doesn't work, you might consider adding a rewrite rule - though it's not recommended. Rewrite rules interrupt the incoming HTTP request and reforms it to match the way your server is set up.

RewriteEngine on 
RewriteRule ^$ index.php

This rewrite rule matches only requests to http://www.propasiarealty.com and will not match http://www.propasiarealty.com/

Using rewrite rules requires mod_rewrite to be installed - more info here http://httpd.apache.org/docs/current/mod/mod_rewrite.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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