Name Files .php Or Change .htaccess?

liunx

Guest
My question: What is the general recommendation for using PHP in most of the files on a site, say for a header/footer tool? Should I mod the .htaccess file to look for php in the .html files or just name everything page.php and let the links handle it? (Users may freak if you put jimscomputing.com/index.php on a business card!)<br /><br />Of course, there is the other obvious thing - there's something that I don't know about or didn't think of! <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /><br /><br />So how do you guys (and gals) do it on your sites?<!--content-->
On my sites, I have a static index page (htm), but then all the links from there are php. that way I don't need any mod rewrites and everything is handled nicely.<br /><br />Andy<!--content-->
Well, you don't even need to put the /index.php part, it works if you write just jimscomputing.com and actually, that's the more usual way <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /><br /><br />Besides, PHP is so common that people are used to see that termination on webpages, so it's not a big shock. Of course, there are people for whom computers are a strange thing, but I think those will freak out even just with the .html <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/laugh.gif" style="vertical-align:middle" emoid=":lol:" border="0" alt="laugh.gif" /><!--content-->
So if I don't have an index.htm or index.html the web browsers will be served up my index.php page? If so that's cool and I didn't know that!<br /><br />You are right, some people get freaked out by the start button!<br /><br />Thanks!<br /> Jim<!--content-->
I used SSI to include the a php random quote in my shtml page like so,<br /><br /><!--#include file="quote.php" --><br /><br />So I kept the vaguely familiar index.shtml.<br /><br />I tried an index.php but just didn't like the extension.<br /><br />Prehaps it's a childhood thing. . . I never liked peas?<br /><br /> Thumbs Up<!--content-->
Yes, that's basically it.<br /><br />Here's how it works on the background:<br />In it's configuration file, Apache has a list of files for which it should look when your browser requests a directory.<br />When that happens, Apache takes a look at the directory you're requesting, to see if there's any of the files it knows of. If there is, it'll serve the first that matches the list. If it doesn't find any matching file, it will show you a directory listing if the directory is set with the permissions for it, or an error page otherwise.<br /><br /><br />For example, imagine you have an index.html and an index.php file on your public_html folder and the index list on your Apache's configuration is the following:<br /><br />index.html index.htm index.php index.shtml<br /><br />If you request <a href="http://jimscomputing.com/" target="_blank">http://jimscomputing.com/</a>, Apache will first look for an index.html file in the public_html directory and serve it.<br />If you delete that file, the next time you request that same URL, Apache will not find index.html, so it will look for an index.htm and will not find one either. It will then look for an index.php file and since there's one, it will serve it.<br />Next, imagine you also delete the index.php file. If you request the same URL once again, Apache will do the same it did before but this time it will not find index.php and when looking for index.shtml it will not find it either, so it will check the directory's permissions and if you are allowed to see it's contents, it will display them, otherwise it will give you the "401 Unauthorized" error.<br /><br /><br />I don't know what's the index files list here at TCH but it could be a useful piece of information. Could someone post that here, please? <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /><!--content-->
That's great info, borfast, thanks!<!--content-->
A little more advance trick... in case you like for your pages to end with .htm or .html... is to do a mod rewrite in .htacess to tell the server to parse the pages as php regardless of the extension.<br /><br />But, for what you are asking, I'd just leave my site with php endings (I do) and folks don't need to type in an index.php file... just your homepage... from that point on, no one really looks at the url, they just follow links.<!--content-->
<!--QuoteBegin-borfast+Jul 26 2003, 09:48 AM--><div class='quotetop'>QUOTE(borfast @ Jul 26 2003, 09:48 AM)</div><div class='quotemain'><!--QuoteEBegin-->I don't know what's the index files list here at TCH but it could be a useful piece of information. Could someone post that here, please?<!--QuoteEnd--></div><!--QuoteEEnd--><br /> On server20 (probably the same in all cPanel sites):<br /><br />DirectoryIndex index.html index.wml index.cgi index.shtml index.jsp index.js index.jp index.php4 index.php3 index.php index.phtml index.htm default.htm default.html home.htm<!--content-->
Thanks idallen. <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /><!--content-->
<!--QuoteBegin-surefire+Jul 26 2003, 06:12 PM--><div class='quotetop'>QUOTE(surefire @ Jul 26 2003, 06:12 PM)</div><div class='quotemain'><!--QuoteEBegin-->I'd just leave my site with php endings (I do) and folks don't need to type in an index.php file...<!--QuoteEnd--></div><!--QuoteEEnd--><br /> Yet another reason that Rock Sign is that we have the servers set up properly AND we have the freedom to dink with our .htaccess files if we want to.<br /><br />I was just marvelling at this yesterday setting up mysql's and things at the click of a button. My last host said "Tell me the password you want on mysql and I'll set it up. Then you can download anything you want to use it, I recommend PHPAdmin" (I think that's the name.) To think, here it is just click-name it- click and all that other stuff is done for us by the gang!<br /><br />I can't possibly say enough about TCH, but I'll start with, again, "THANKS!"<!--content-->
I use a mailing list program that for some reason requires the default file on my directories be set to index.php and not index.html ... .I have no idea why, but I can't get it work and I can't figure out a way to change the default...is there a way?<br /><br />Justin<!--content-->
Jim,<br /><br />Ever since I started using any php at all (and it's still not much), I've named every file I create .php. Even if there is no php in it!! That way, if I want to add some later, I don't have to worry about redirects or changing file names or any of that stuff!! I haven't come across any disadvantages, yet, in doing it this way!!<!--content-->
Justin: You'd probably have to change it in the mailing list program.<br /><br /><br />Tracy: I have found the same thing to be true. The reason for this question was really how little I knew about the behind-the-scenes of web sites and how limited other hosts are.<br /><br />Once I found out about the .htaccess and how to get Apache to parse the files no matter which name I used everything got better. As I said previously in this thread. TCH is awesome and I'm so glad all of us found it. Now we just need to tell everyone else about it! <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /><!--content-->
I tend to use PHP for everything...<br /><br />I tend to concur with the expression that if your index page is in PHP and everybody follows links around your site, they generally don't care what the address of the page is...<br /><br />I could even be <!-- w --><a class="postlink" href="http://www.domain.com/sub1/sub2/sub3/sub4/index_file_handler.release1.php">www.domain.com/sub1/sub2/sub3/sub4/inde ... lease1.php</a><!-- w --><br /><br />lol...<!--content-->
 
Back
Top