Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

I have a php file, which when called creates a webpage. However, there are some things I can't do with this. Is it possible to mirror that webpage on another page, ie. have index.html calling and displaying the php file every time?

Hope that makes sense! Thank you.

share|improve this question
Are you asking for when people load index.html, it loads for example index.php instead? – MrStatic Feb 28 '10 at 18:24
Sort of. Yes it needs to do that, but it needs to display what would be displayed by loading index.php on the index.html page. – James Apache Feb 28 '10 at 19:35
up vote 0 down vote accepted

I'm no web designer but to do the same thing on our site we use <meta http-equiv="REFRESH" content="0;url=/index.php"> inside the head of an otherwise empty index.html. That will make calls to index.html end up at index.php.

share|improve this answer

HTML pages are static text files, they are not processed by the web server and so can't do anything at all. Another PHP file would instead be able to do this, so you could have f.e. "index.php" call "someotherfile.php".

If you absolutely want your users to be able to request "index.html" and instead obtain something else, then you'll need some URL rewriting.

share|improve this answer

Is the requirement that when you hit the index.html content shows by default, but you want the index.php stuff to show? If that is the case, you can set the apache "DirectoryIndex" directive to include index.php

If you want users to hit index.html, and get PHP interpreted stuff inside the page, you can't really do that. Technically you could tell PHP to interpret files that end in .html, but I wouldn't really recommend doing that.

As Massimo said, if you want users to specificly hit index.html and end up witha php processed page, RewriteRules would be required for that.

share|improve this answer

If the directory containing the index.html has "FollowSymLinks" enabled in Apache, you can simply symlink the php file.

ln -s thephpfile.php index.html

You could also change the default file that's used for indexes using the DirectoryIndex parameter.

It is notable the enabling FollowSymLinks is considered to introduce security risk. Read this and make up your own mind.

Massimo makes some applicable points regarding PHP parsing. Important to consider.

Documentation for Apache 2.2:

share|improve this answer

Your Answer


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