I want http://www.foo.com/ to internally point to /var/www/home.php and http://www.foo.com/home.php to be redirected to http://www.foo.com/.

Thus, I would like to fix the old http://www.foo.com/home.php to the new one http://www.foo.com/. But I always get infinite loop or other strange error no matter what.

  • What rule are you trying, so we can tell you what's wrong with it.
    – DerfK
    Feb 20 '11 at 18:42

If you just want home.php to be the directory index (as opposed to the usual index.php, etc), you don't need the overhead of mod_rewrite to do it:

DirectoryIndex home.php index.php index.html // and so on

It works in directory .htaccess files too, if you want to maintain a different default elsewhere. More details via mod_dir.


In your virtualhost definition for foo.com:

DocumentRoot /var/www/

Then your rewrite rule:

RewriteRule ^/home.php$ /

If you will redirect from foo.com to home.php then it would ofcourse go in to infinite loop. Rather try to include the home.php page in the index page of foo.com/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy