Forum Moderators: coopster

Message Too Old, No Replies

Is the filext .php a must? And is it SE friendly?

When *all* the pages are PHP?

         

picophd

9:14 pm on Nov 17, 2004 (gmt 0)

10+ Year Member



Greetings,
Is it a requirement to name any PHP file of a web page with the .php extension, in the form of index.php, for instance? Or can you name the file index.htm, even though it has <?php...?> code in it, and it would still work? I tested this index.htm file that has PHP code in it on my own computer, and it worked, or the page showed correctly. But when I uploaded the file to my website server, named with an .htm extension, it did not display correctly. Is there something wrong with the server, to which I have to draw the administrator's attention?

Also, if the file is named index.php, is it still possible to only give people the www.example.com part without the /index.php, and the browser would show the website normally? I'm asking because I know that as long as the file after the slash / is called index.htm or index.html, then you don't have to include the index.htm part in the address, which makes whichever address you're giving look nicer and easier to remember. But when I tried going to a certain address without putting the index.PHP part, it didn't work. So, again, does the administrator of the website server or host have to do something to make this work with index.php files just as it works with index.htm files?

Are PHP files search-engine friendly? I know that a lot of the code inside a php file sometimes simply embeds X/HTML code into the page before sending it to the client, but generally speaking, are there any caveats, related to search engines, of which to be aware when all the pages in a website are PHP? For instance, is it a problem that the raw .php file does not have any "content", and it gets all the content from certain other .php or .htm files?

Finally, I heard of a certain method, which makes all the addresses within any website search-engine, bookmark, AND linking friendly, i.e., it gives you the ability to have a certain fixed URI for every item in your website, regardless of its file extension. And if someone had bookmarked a certain page in your site one year ago, but you changed the technology you use or something, then no one ends up with linkrot. What is this method exactly and where can I learn its implementation?

Salsa

9:25 pm on Nov 17, 2004 (gmt 0)

10+ Year Member



Hi picophd,

These questions have been answered a bunch. Go to Site Search [webmasterworld.com] and put in something like "php search engines" to look at past discussions.

picophd

11:32 pm on Nov 17, 2004 (gmt 0)

10+ Year Member



Thanks, Salsa. That indeed does it. I didn't even know that WW has a search capability! I heard the database here depends on Google for searching, or something along the same lines.

I have to take my final question to a separate post now, though. But at least now there's only one question and very specific.

Hester

9:42 am on Nov 18, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Google, for instance, doesn't care how a page is made - be it from PHP or ASP etc. It just takes the completed page sent from the server, just like the browser.

I have heard it does not like question marks in the URL, though personally I've not had a problem there. Nor does it like session IDs. But just the php extension is not a problem.

Is it a requirement to name any PHP file of a web page with the .php extension, in the form of index.php, for instance? Or can you name the file index.htm, even though it has <?php...?> code in it, and it would still work? I tested this index.htm file that has PHP code in it on my own computer, and it worked, or the page showed correctly. But when I uploaded the file to my website server, named with an .htm extension, it did not display correctly. Is there something wrong with the server, to which I have to draw the administrator's attention?

LOL. Only files with the extension '.php' are sent to the PHP parser. HTML files will not be parsed.

Also, if the file is named index.php, is it still possible to only give people the www.example.com part without the /index.php, and the browser would show the website normally?

Yes, so long as there isn't another page with the '.html' extension that would take precedence. Eg: if you have 'index.html' and also 'index.php', I'm guessing the first one is used first. But just use 'index.php' and you'll be fine.

Finally, I heard of a certain method, which makes all the addresses within any website search-engine, bookmark, AND linking friendly, i.e., it gives you the ability to have a certain fixed URI for every item in your website, regardless of its file extension. And if someone had bookmarked a certain page in your site one year ago, but you changed the technology you use or something, then no one ends up with linkrot. What is this method exactly and where can I learn its implementation?

[webmasterworld.com...]

Oh wait, you posted that one! Well I hope someone will have helped answer the question there...

bloke in a box

10:57 am on Nov 18, 2004 (gmt 0)

10+ Year Member



.htm files can indeed be passed to the php parser!

To make it work on your server; change the following in your httpd.conf:

AddType application/x-httpd-php .php

to the following:

AddType application/x-httpd-php .php .htm .html

The major problem with this is that every .htm / .html file will be php parsed which could cause a performance problems.

Alternatively you can also use .htaccess to 'forward' all .htm files to a .php equivalent.

Although by the way, if you're not on Apache the above will not work properly, heh :)

bloke in a box

11:00 am on Nov 18, 2004 (gmt 0)

10+ Year Member



It depends on the order set for the default page.

On Apache it tends to be index.html > index.htm > index.php (IIRC), this can be changed although you'll have to google [google.com] for it. :).

Ie that is to say www.widgets.com is automatically going to pick up www.widgets.com/index.html/.htm/.php etc.

My old workplace's IIS used to default to default.asp then index.html (for some unknown reason)

Hope that helps.

coopster

11:12 am on Nov 18, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



No need to google, bloke, in Apache it is the DirectoryIndex [httpd.apache.org] configuration directive.

picophd

12:06 pm on Nov 18, 2004 (gmt 0)

10+ Year Member



And someone else, in another similar topic, had mentiond a brilliant idea to not load the server with unnecessary parsing of pure X/HTML files: simply name your pure HTML files with the extension .html, for instance, but add the extension .htm only with the .php and so, to that line in the httpd.conf file.