Sign up ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

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 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

1 Answer 1

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.