index.html -> index.php for main page

  • conorific
  • Proficient
  • Proficient
  • User avatar
  • Posts: 350
  • Loc: NY

Post 3+ Months Ago

Does anyone know how I can make index.php the main page? For example, when you go to a domain name, by default, it points to index.htm or html. Is there any way I can change that to index.php? Thanks!
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • Tazel
  • Student
  • Student
  • Tazel
  • Posts: 97

Post 3+ Months Ago

Are you running apache? If so, there's a part of the httpd.conf file that you can change which has list of filenames it can search for for the default page.
  • conorific
  • Proficient
  • Proficient
  • User avatar
  • Posts: 350
  • Loc: NY

Post 3+ Months Ago

I do, and I know what's you're talking about. Unfortunately, I'm not the admin and I don't have access to it. Is there another solution or will I have to screw with splash pages?
  • lostinbeta
  • Guru
  • Guru
  • User avatar
  • Posts: 1402
  • Loc: Philadelphia, PA

Post 3+ Months Ago

It should point to any file with the name "index". At least that is how every server I have used works.

Typically there is a set default of .htm or .html, where if multiple index files exist the default is taken, but if theres only one index file, then that one should be chosen.
  • RichB
  • Guru
  • Guru
  • User avatar
  • Posts: 1121
  • Loc: Boston

Post 3+ Months Ago

If you don't have access to your httpd.conf file you can use .htaccess to specify it by using the following (assuming your host allows the use of .htaccess of course):

Code: [ Select ]
DirectoryIndex index.php index.html


Precedence is from left to right. In other words if you have both an index.php and an index.html with an .htaccess file containing the line above the index.php would take precedence over the html file. I think hosts that provide php usually have index.php as an option inside httpd.conf, but the order of precedence might be different - in other words index.html might come first, so you might try making sure you don't have index.html in the same directory with index.php, or you can override it with an.htaccess file. At least that's how I understand it.
  • Axe
  • Genius
  • Genius
  • User avatar
  • Posts: 5739
  • Loc: Sub-level 28

Post 3+ Months Ago

Sounds about right to me RichB, that's how I've done it in the past with osCommerce (it uses default.php as its "home" page).
  • rjmthezonenet
  • Expert
  • Expert
  • User avatar
  • Posts: 526
  • Loc: St. John's, Newfoundland, Canada

Post 3+ Months Ago

Allowing .htaccess files is an administrator setting; also set in httpd.conf. You can try it... but there is not guarantee it will work. In fact, .htaccess files are often disabled because of the performance penalty. Stop guessing and ask your sysadmin! :-)
  • conorific
  • Proficient
  • Proficient
  • User avatar
  • Posts: 350
  • Loc: NY

Post 3+ Months Ago

Who's guessing? He's a busy guy and I get my service for free, so I ask him at a time at his convienence, not mine. But thanks for your help.
  • Axe
  • Genius
  • Genius
  • User avatar
  • Posts: 5739
  • Loc: Sub-level 28

Post 3+ Months Ago

No need to guess, try it, see if it works.

Make the .htaccess do the DirectoryIndex, if it works, carry on n' don't worry about it, if it doesn't, contact your friendly neighbourhood admin :)

Sure, he's a busy guy and you get your service for free, but he doesn't know if you need to ask something until you actually ask him. Pop him an E-Mail if you need to, tell him there's no rush to reply, but at least let him know you have a question :)

like rjm says, there are many admins who disable .htaccess, to some degree or other. There are MANY things in the Apache/PHP/other configs that can be enabled & disabled via .htaccess, and each of those can be turned on or off through the Apache config. Most linux boxes that I've been hosting at least have the DirectoryIndex override enabled.
  • rjmthezonenet
  • Expert
  • Expert
  • User avatar
  • Posts: 526
  • Loc: St. John's, Newfoundland, Canada

Post 3+ Months Ago

Yeah, what the heck. Save the following in a text file in the root directory of your web pages called .htaccess

Code: [ Select ]
DirectoryIndex index.html index.php


(I can't tell if this is what RichB posted because of a display issue with those code tags and my web browser. Arrrg!)

On futher thought, maybe you should recommend your sysadmin do this globally. I can't see how it would be an issue to add that to the end of the DirectoryIndex directive in the .conf file.
  • rjmthezonenet
  • Expert
  • Expert
  • User avatar
  • Posts: 526
  • Loc: St. John's, Newfoundland, Canada

Post 3+ Months Ago

BTW: If you're curious about the .htaccess file. Read these two pages:

http://apache-server.com/tutorials/ATus ... ccess.html
http://httpd.apache.org/docs/mod/directives.html
  • stinger
  • Graduate
  • Graduate
  • stinger
  • Posts: 157
  • Loc: San Jose, CA

Post 3+ Months Ago

I hope this isn't tooo ignorant, but why can't you just name the index.php as index.html? It works for me. and then it won't matter what the server is running ie. .(linux, unix, apache etx.)
  • Axe
  • Genius
  • Genius
  • User avatar
  • Posts: 5739
  • Loc: Sub-level 28

Post 3+ Months Ago

Because Apache won't parse .html files for PHP commands (unless you set Apache up specifically to do that, which most won't because it puts a hell of a strain on the server if most of the .html files being loaded on the server don't contain PHP commands).

Also, any links to index.php on the site would now be pointing to a page that doesn't exist.

If you're running a store or content management system with potentially hundreds of files linking to index.php, that's alot of stuff to edit :)
  • stinger
  • Graduate
  • Graduate
  • stinger
  • Posts: 157
  • Loc: San Jose, CA

Post 3+ Months Ago

John -
Thanks for the info. I suppose I have been spoiled and have not had to work on a Apache server. :)
  • conorific
  • Proficient
  • Proficient
  • User avatar
  • Posts: 350
  • Loc: NY

Post 3+ Months Ago

Thanky...when he gets back, I'll talk to him about it.

Post Information

  • Total Posts in this topic: 15 posts
  • Users browsing this forum: No registered users and 36 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.