2
votes

I have a site (php) which i uploaded to a host and it is unreachable, giving the 500 internal server error message. I have the same site with the same .htaccess on localhost, and also on 2 other hosts, those are working perfectly.

The server's error message is the following: AH01276: Cannot serve directory /home/user/public_html/

This is my .htaccess in the public_html folder (as i said it is the same on 2 other hosts with no problem)

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteBase /public_html/

    RewriteRule    ^$    /public/index.php    [QSA,L]
    RewriteRule    (.*) /public/$1    [QSA,L]
</IfModule>

If i comment out the

RewriteRule    (.*) /public/$1    [QSA,L]
line the site loads to the login page, but after i login, it gives 404 error.

The site is php, uses MVC model, redirecting every request to public/index.php

Does anyone have an idea what could go wrong on this host ?

I also have an another .htaccess inside the document_root/public/ folder that is also the same on every host:

Options -MultiViews
RewriteEngine On

RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
 
#RewriteRule ^(.*)$ index.php?url=$1 [PT,L]
RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]
1
What have you tried to resolve the problem? How is this related to PHP, if Apache already throws an error? - Nico Haase
well i asked the host provider, he suggested to comment out that line i mentioned, and that is it. it is only related to php because the site im trying to make work is in php. - Ninet9
Is that the full error message? Or does it continue with “No matching DirectoryIndex (index.php,index.html) found, and server-generated directory index forbidden by Options directive”, as researching the error code suggests would usually be the case? - CBroe
AH01276: Cannot serve directory /home/user/public_html/: No matching DirectoryIndex (index.php,index.php5,index.php4,index.php3,index.perl,index.pl,index.plx,index.ppl,index.cgi,index.jsp,index.jp,index.phtml,index.shtml,index.xhtml,index.html,index.htm,index.wml,Default.h,tml,Default.htm,default.html,default.htm,home.html,home.htm,index.js) found, and server-generated directory index forbidden by Options directive - Ninet9

1 Answers

1
votes

You should remove the RewriteBase directive from both .htaccess files. In your root .htaccess file it is not being used (but is set incorrectly). In the /public/.htaccess file the RewriteBase is set incorrectly and will end up rewriting requests back to the root (which is presumably not the intention).

Also ensure that the DirectoryIndex is set correctly in the /public/.htaccess file:

DirectoryIndex index.php