Webmasters Stack Exchange is a question and answer site for pro webmasters. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Idea is:

if      URL = "http:/localhost/site/"
else if URL = "http:/localhost/site"

redirect to


Can this be done with .htaccess / Apache mod_rewrite and how?

share|improve this question

migrated from stackoverflow.com Jan 27 '12 at 3:14

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

Yes, it can be done with mod_rewrite. – Marc B Jan 22 '12 at 6:48
Why aren't you using DirectoryIndex index.html? – Jon Lin Jan 22 '12 at 6:50

You could simple add this in your htaccess

DirectoryIndex index.html

share|improve this answer
Why not the main Apache configuration file? Apache re-reads, re-parses, and re-configures whenever it discovers an .htaccess file in the directory structure. You might as well promote the mechanism that has the least impact... – sarnold Jan 24 '12 at 0:13

Your Answer


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