FRIHOSTFORUMSSEARCHFAQTOSBLOGSCOMPETITIONS
You are invited to Log in or Register a free Frihost Account!


PHP in HTM or vice versa for search ranking





FunDa
If I want to make a site with mostly html but a little php too, should I name the file as .php

Will it have better search engine rankings if I name it as .htm (or .html)

But then I would have to make the server parse the ,htm file for php right ?

How do I do that ?

A lot of silly questions, but please tell me if you know ... Very Happy
ncwdavid
Well if the page will have only a little php then it has to be ".php" but I would say use.php for all the pages instead of having some html and php ones. If they are all the same it would look better then all different and maybe easier for you to organise them.

I don't think the type of file matters where you come in search engine rankings.
SlowWalkere
I'm not sure if the extension has anything to do with search engine ranking, but I don't think that it does. As long as there are permanent files for the search engine to crawl that have the content in them, .php or .html will do the same thing.

As for making all of the file extensions the same, you have two choices. You could change all filenames to .php, which will work just fine.

Or, if use the .htaccess file, you can set up the server to parse .html or .htm files as if they were php. The end result is the same (every page is sent through php), but the file extensions will appear as .html instead of .php.

I have never actually done this myself, but it appears to be fairly simple. There should be dozens of tutorials on how to use .htaccess to change the file extensions that are read as php, including this one.

Essentially, you create a plain text file called .htaccess, and upload it to the root directory of your site. In this case you would want to add these two lines...

Code:
RemoveHandler .html .htm
AddType application/x-httpd-php .php .htm .html


Good luck,
- Walkere
FunDa
Thank u ncwdavid and SlowWalkere Smile
That answered my question.

Is there any security issue when parsing all files through php ?
I mean, if visitors are allowed to upload and download files, is there a chance that they could upload and execute a different extension file as php ?
shamil
FunDa wrote:
Thank u ncwdavid and SlowWalkere Smile
That answered my question.

Is there any security issue when parsing all files through php ?
I mean, if visitors are allowed to upload and download files, is there a chance that they could upload and execute a different extension file as php ?

Of course there is security issue(already). You must prevent it by not allowing certain file extensions to upload.
FunDa
Can they upload php script in , say a .jpg file and then run it.

Or more realistically, in a .htm file and then run it (coz the server is set to parse htm files for php) ?
SlowWalkere
With the code snippet that I posted, the "AddType" line sets the server to interpret all of the given file-types as php. So, in the example, .php, .htm, and .html files would all be run through php before getting sent to the user.

So, to answer your question, yes and no. If a user uploads a .jpg file, it will still load up like a normal picture.

If a user uploads a .htm/.html file, I think the server would execute the script as normal. So, you would need to restrict any upload-access to not include those three file extensions (if you're worried about the security problems).

There are two solutions that I see. One, you could just bar all of those file types. If a user wants to share a .htm/.html file with other users, he/she will have to compress the file to a .zip or .rar format to upload it.

Or, if you want to allow users to post viewable html, you can set the server to interpret one extension as html and one extension as php. For example, tell the server that .html should be run by php, but .htm should not. Then, users would be able to upload .htm files only.

Good luck,
- Walkere
snowboardalliance
Also, if you parse all .html through php it may be slower, though I'm sure it is insignificant, it may be a factor. Only see it as an issue if you are already worried about people uploading .html files, in which case you could just have security in the upload to prevent this.
Related topics
Which script language do you like most?
Things that you MUST not SUGGEST -- READ BEFORE POSTING!
[Dúvidas] O que é DNS e serve para que?
Master Tutorial on SEO
JAVASCRIPT serializer/deserializer
Forum Suggestion
Marketing and Business Planning
Making a Dynamic link button
What file extension should I use ?
Tony Blair
Internet dating - love or sex?
Energy and Momentum in a Closed System
Big, complicated php project: 10,000 frih$
Which language should I learn during my semester break?
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.