Index.php does not open up

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View


I am a newbie in PHP and I am enthusiastically trying out things. I've
just replaced my

       index.html (

file with


with of course a few lines of php code, which I am sure they are all
correct as far as the syntax goes. I expect the file (index.php) to be
loaded in to the browser window upon launching the browser. It's not
doing that; instead, it loads  the apache index file. (Oh, I forgot...
I am running  php 5 and apache and modified idex.html to
indexHtml.html to avoid the webserver serving the page). I guess that I
need to insert a line somewhere in the apache config file but I don't

Any help, please.


Re: Index.php does not open up

This is a multi-part message in MIME format.
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Jofio wrote:

Quoted text here. Click to load it

Huh? Do you mean that you renamed the current index.html ->
indexHtml.html? OK, where's your index.html page now?

Quoted text here. Click to load it

First make sure that your index.php page really does work by specifying
it completely. IOW, if your index.php page is at your DocumentRoot then
specify http://<myserver>/index.php. See if that works.

There's no real magic here. Apache, and other web servers for that
matter, is configured to open up a default file if none is specified.
Traditionally that's index.html but more defaults have crept in.

I'm running Apache 2 on Linux. Adjust for your OS. On my OS the
configuration files are under /etc/httpd/conf (some OSes use
/etc/apache/conf or /etc/apache2/conf). Additionally Apache has several
configuration files. A simple grep yeilds me:

$ grep index.php *.conf
commonhttpd.conf:    DirectoryIndex index.html index.html.var index.php
index.php3 index.shtml index.cgi index.htm Default.htm default.htm

So then, it's in the commonhttpd.conf file in /etc/httpd/conf for me.
The parameter is called DirectoryIndex. What follows is the list of
files that Apache will look for when you specify a URL that points to a
directory instead of a file. In my case it's index.html followed by
index.html.var (I believe the .var files are an Apache 2 convention for
multiple languages. I don't use them so I haven't investigated them
further) then index.php (Viola!), index.php3 (old - I probably could get
rid of this), index.shtml (shtml are for server parsed files. I played
with that once), index.cgi (IOW any index.cgi but generally I name my
Perl scripts .cgi), (again, for Perl), index.htm (old MS
heritage 3 character extensions, which, BTW, Win95 and above can do more
than 3 character extensions) Default.htm and default.htm (Yuck! IIS
influenced names!).

So then just stick the index.php in the list of DirectoryIndex files in
whatever order of importance you see fit (When Apache searches for a
DirectoryIndex first one found wins!) and restart Apache. For exmaple,
given my configuration above if I had an index.html it would be server
first before index.php. That's OK for me because if I consciously
rewrite an index.html to be dynamic making it an index.php I am
replacing the index.html so I'd simply remove it.

I used to work at a factory where they made hydrants; but you couldn't
park anywhere near the place.

Content-Type: text/x-vcard; charset=utf-8;
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;

fn:Andrew DeFaria
adr:;;6265 Kelez Court;San Jose;California;95120-2819;United States


Re: Index.php does not open up

I have renamed index.html to indexHtml.html so to avoid the browser
from opening the file by default at the launching of a browser. Instead
I want wanted the index.php to open up by default....

and oh yes, typing http://localhost/index.php does open the page.
However, problem is it doesn't open up by default as it should like

Win XP pro is my OS.

I've just uppended  index.php  in the DirectoryIndex line in the
apache's httpd config file as shown below

DirectoryIndex index.html index.php index.html.var

.....don't seem to see any difference.
But nevertheless,  thanks alot.


Re: Index.php does not open up

Kimmo Laine wrote:
Quoted text here. Click to load it

Unless next_page.php generates PHP, the script with this include will
only get HTML.

Quoted text here. Click to load it


    if (isset($_GET['foo'])) {
      echo '<?php echo $_GET[\'foo\']; ?>';
    } else {
      echo '<?php echo \'Not available\'; ?>';

File not found: (R)esume, (R)etry, (R)erun, (R)eturn, (R)eboot

Site Timeline