I have index.html on my html_directory on my website also I entered a rule as follows:

RewriteRule ^index.html$ newindex.php

It seems requests to my site is routing to my index.html file , my questions are:

  1. Do I need to have index.html file on my public_html directory or I can remove it?
  2. Is my rewrite rule correct?
  3. Based on my rule on .htaccess which page is open : index.html or newindex.php?

2 Answers 2


Hope i understand you correctly, you want to define the entry page newindex.php for your directory? There is no need for rewriting, simply define which page acts as the entry page. In the .htaccess file you can define:

DirectoryIndex newindex.php

Now, if anybody calls your directory http://www.example.com, the page http://www.example.com/newindex.php will be shown. The file index.html is not necessary in this case, it's name is just a convention.


If you don't want to set DirectoryIndex like martinstoeckli wrote I would improve your rewrite a bit:

RewriteRule ^index\.html$ newindex.php [R=301,L]
  1. you can remove the index.html - it's not needed anymore with this rule
  2. no, not completely. Dots should be escaped in regexp with \. Because it's obviously your old entrypage you should redirect "permanent" (HTTP Statuscode 301) your page.
  3. the newindex.php

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.