Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

My Domain points to the directory public_html. In the directory public_html/php is my index.php file.

Now I want that the URL points to *public_html/php/index.php*. I must do this with mod_rewrite because I have no access to the httpd.conf to do something wth Alias oder DocumentBase.

In the directory public_html is my .htacces filewith the following content:

RewriteEngine on
RewriteCond %{HTTP_HOST}$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /php/index.php [L,QSA]

This do half of the job, because when I enter something like in my browser it points to *public_html/php/index.php* as I want it to do. But when I just enter it points to *public_html*.

What can I do to fix this?

share|improve this question

migrated from Oct 29 '12 at 16:53

This question came from our site for professional and enthusiast programmers.

1 Answer 1

up vote 1 down vote accepted
RewriteCond %{REQUEST_FILENAME} !-f

The !-f flag means "if the requested file doesn't exist". When accessing, the Apache DirectoryIndex directive redirects the request to /public_html/index.php, does this file exist? Because if it does, your RewriteRule is ignored. You have to either remove the RewriteCond above, or remove the /public_html/index.php file.

share|improve this answer
Ok, thanks for your hint, there was a index.html in the public_html folder from my hoster. I deleted this file and everything works. Thank you very much :) – rotespferd Oct 29 '12 at 12:17

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.