...

View Full Version : index.php vs index.html



ArcticFox
03-14-2007, 06:47 AM
index.php vs index.html

Is there any reason for me to have two pages?

If my site is in PHP, is there a situation where the browser won't go to an index.php page?

Sylvester21
03-14-2007, 06:59 AM
Normally when you have an index.html and an index.php file, the index.html file should be displayed. Comes in handy when updating your site, you can show an index.html file so people see it's being updated.

westmatrix99
03-14-2007, 07:10 AM
You can use both and just refresh to index.php, the reason is when you change your code on your site the index.php sometimes takes about 2 hours to refresh on certain ISP's so you wont see changes straight away.

I am not sure how your ISP works, but mine says wait two hours or less.
I know that you can use no cache not to cache the page but that's another post.
Cheers
West

the-dream
03-14-2007, 01:49 PM
You could meta refresh to the index.php or use JavaScript :p

aedrin
03-14-2007, 03:19 PM
the reason is when you change your code on your site the index.php sometimes takes about 2 hours to refresh on certain ISP's so you wont see changes straight away.

I know I would personally never consider a host with such a curious operating structure. There is no need to have to wait 2 hours.

One of my hosting providers sometimes (once or twice during sessions) will take a minute to update. To me this is too much already.


Is there any reason for me to have two pages?

There is virtually no reason. Your server determines which is picked. No browser inadequacy will ever require an index.html.


Normally when you have an index.html and an index.php file, the index.html file should be displayed. Comes in handy when updating your site, you can show an index.html file so people see it's being updated.

This is the only reason to have an index.html file around, but it wouldn't contain the actual site. Your server would have to be set up to prefer index.html over index.php (which it usually is). Even then, a page like this shouldn't be necessary with PHP.

RTrev
03-14-2007, 06:47 PM
I tend to use the .htaccess file to tell each directory which file should be opened by default.. and then I don't have a whole bunch of index.* files to deal with. I find this helpful. A friend recently copied the wrong index.* file into one his directories, and then discovered hours later that he'd screwed up. Seems easiest to me to keep them named for the project, and then even if one is accidentally FTP'd to the wrong area it won't make any difference as it won't be used anyway. Pluses or minuses to this approach?

westmatrix99
03-19-2007, 07:01 AM
index.php vs index.html
Is there any reason for me to have two pages?
If my site is in PHP, is there a situation where the browser won't go to an index.php page?

I like Sylvester21's idea it works, or get ".htaccess" help and work from there.


Cheers
West

RTrev
03-19-2007, 07:13 AM
Following up on this, but perhaps at a bit of a tangent, do folks generally name their pages .php when the pages contain any PHP code at all?

I'm thinking of cases where 99% of the page is straight HTML, with just a line or two of PHP code inserted where needed. Is there any advantage or disadvantage to naming such pages with .html? I'm learning PHP now, and tend to name the page for the predominant code used. Even when named .html, all but the *output* of the PHP code will still be hidden from anyone downloading the page, correct?

aedrin
03-19-2007, 03:06 PM
If it contains, it -should- be named .php.

This is similar to using <? instead of <?php. It works, as long as your server is configured to support it, but not all servers are.

Not all servers are configured to treat normal .html files as containing PHP code. Most likely very few of them are.

Also, don't use the .inc or .include extension for files you include. ;)

firepages
03-19-2007, 03:08 PM
I know I would personally never consider a host with such a curious operating structure. There is no need to have to wait 2 hours.


Sadly many smaller ISP's in backward countries like Australia (I kid you not) still use proxy servers with ridiculous cache times.


Is there any advantage or disadvantage to naming such pages with .html?
You can configure your webserver to parse .html as .php but that means an extra load on pure html pages that are then thown through the parser without reason.


If my site is in PHP, is there a situation where the browser won't go to an index.php page?
depends how your webserver is configured ... with the following the php file will always be parsed first, but different hosts do things in different ways.
(.htaccess or server config)
DirectoryIndex index.php index.html

using index.html as an 'offline, back soon' sort of page has merits but you still need to rename the index.php or the DirectoryIndex directive to force its use

RTrev
03-19-2007, 04:07 PM
If it contains, it -should- be named .php.

This is similar to using <? instead of <?php. It works, as long as your server is configured to support it, but not all servers are.

Not all servers are configured to treat normal .html files as containing PHP code. Most likely very few of them are.

Also, don't use the .inc or .include extension for files you include. ;)

Ahah, I guess the 1&1 servers must be set to run .html files through the PHP parser.. as they work. I'll rename to .php -- thanks for the heads up on that one!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum