htaccess generates an 500 internal server error

Viewed 333

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 Answers

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
Related