Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

Now I want that the URL example.com 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} exaple.com$
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 example.com/s in my browser it points to *public_html/php/index.php* as I want it to do. But when I just enter example.com it points to *public_html*.

What can I do to fix this?

share|improve this question

migrated from stackoverflow.com 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 example.com, 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

 
discard

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