473,378 Members | 1,438 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Index.php does not open up

Hello,

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

index.html (

file with

index.php

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 2.xxx 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
how...

Any help, please.

jofio

Jul 17 '05 #1
3 6065
Jofio wrote:
Hello,

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

index.html (

file with

index.php

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 2.xxx and modified idex.html to
indexHtml.html to avoid the webserver serving the page).
Huh? Do you mean that you renamed the current index.html ->
indexHtml.html? OK, where's your index.html page now?
I guess that I need to insert a line somewhere in the apache config
file but I don't how...

Any help, please.


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.pl 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), index.pl (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.

Jul 17 '05 #2
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
index.html.

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

Jul 17 '05 #3
Jofio wrote:
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....
What a browser opens as a default page is a function of what you tell
the browser to open as a default - not a function of the web server! My
default "home" page is set to http://defaria.com on the browser I run at
home - Firefox. At work it's set to http://news.google.com. Notice none
of these involve localhost!
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
index.html.
You could always set your default home page to
http://localhost/index.php! ;-)

What is your default home page set to in your browser? For that matter
WHAT'S YOUR BROWSER! You neglected to mention that.
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
What's an "uppended"?!? 'Cause I see index.php between index.html and
index.html.var. Is that what "uppended" means? :-)
....don't seem to see any difference.
Did you follow the other advice to restart Apache? Changes to the config
will not go into effect until you do that. Also, is there an index.html
in your DocumentRoot?
But nevertheless, thanks alot.


Again this is not rocket science here. If you specify http://localhost
in the address bar (or configure it for the default page to open for
your browser) then the web server at localhost (default port of 80) will
be contacted. The server will look at what DocumentRoot is set to (for
example, C:\HTDocs). Since you didn't specify an actual file then the
server will search for C:\HTDocs\index.html, because that is what you
listed first in DirectoryIndex. If that file is found it will be
retrieved - end of search. If not then the search continues to
C:\HTDocs\index.php. Assuming you've configured the type for .php files
to run through PHP it will be run through PHP and the resulting file
will be displayed. If C:\HTDocs\index.php is not found then
C:\HTDocs\index.html.var will be use if it is found. Finally, if none
are found then the server will return 404.
--
If love is blind, why is lingerie so popular?
Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Guy Deprez | last post by:
Hi, i'm having a problem to create indexes. STEP 1 ----------- Connection is OK (you can find the string at the end of the message) Table ("Couleurs") creation is OK STEP 2. Index Creation
1
by: Robert Oschler | last post by:
I read a while back that MySQL will only use one index per query. (If this is not so, please tell me and point me to a doc that gives a good explanation of MySQL's current index usage policy). ...
3
by: Gerry Abbott | last post by:
Hi all. Could someone tell me is this number fixed when the item is created, or can it be changed? So for example if there are three forms, with index 0,1,2 and form 1 is deleted, does form...
1
by: Average Bear | last post by:
If anyone could help with this one, I am a bit puzzled. I understand you can create an index using two fields of a database, then use the seek method to find a record based on both fields. My...
3
by: Eric Davies | last post by:
We've implemented a 5D box data type and have implemented both RTree and GiST access methods under PostgresSQL 7.4 and PostgresSQL 7.4.1. The 5D box internally looks like: struct Box5D{ float...
14
by: oLgAa25 | last post by:
Hello all, I am back I have this question everything compiles fine, but I just need to check for an index that is more than the array size. Although it says out of bound, but it is still...
1
by: jhall | last post by:
At some point an index has been added to a table in my Access DB that does not allow duplicates. I can't see where I ever put an index on this field. But, when I tried to add 2nd records with a...
4
by: Owen Jenkins | last post by:
Hi, No-one replied to this when I sent it last week. Any bites out there today?? ----- My application allows users to create a new back end for separate purposes. It does this by using Make...
0
by: Pierre | last post by:
Hello, I'm having problems to use the get method on a cursor with an index (secondary database). I've read Oracle's docs but there are mainly in C, JAVA and C++. So no python docs! actually,...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.