Forum Moderators: coopster

Message Too Old, No Replies

I need to change my file extensions to php

Totally lost here

         

Fryman

3:49 am on Feb 4, 2004 (gmt 0)

10+ Year Member



Hi! I am installing an affiliate scrip at my site. However, it says I need to change several pages to a php extension so it can track the affiliate sells. The problem is that those pages have a Google PR3, and if I change the file from html to php I'll loose my PR!

What can I do?

Thanks for your help!

seomike2003

7:28 am on Feb 4, 2004 (gmt 0)



Add this to your .htaccess file and it will tell php to parse .htm .html files as if they were .php files
:)

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

Fryman

6:01 pm on Feb 4, 2004 (gmt 0)

10+ Year Member



Wow, I'm glad to here that there is a solution to my problem, but could you explain it to me like if you were talking to a 10 year old? I don't know anything about scripts, I am just following a step by step instalation of this script and got stuck here.

Thanks!

coopster

6:21 pm on Feb 4, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



AddType [httpd.apache.org] is an Apache HTTP Server directive that maps the given filename extensions onto the specified content type. .htaccess [httpd.apache.org] files provide a way to make configuration changes on a per-directory basis.

Basically it is saying "if I see any requests for documents of type

.php
.htm
or
.html
, I'll process them with the PHP parser."

Fryman

6:36 pm on Feb 4, 2004 (gmt 0)

10+ Year Member



Thanks, but... Now what? lol. Ok, so I'll create a .htaccess file with the instructions you gave me. Do I put it in the root directory? Is that all I need to do, or do I need to type some code at my HTML pages?
As I said, I need step by step insctructions, first time Im using a php script

Thanks for your help

isitreal

6:38 pm on Feb 4, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Here's fairly complete directions, I sympathize, .htaccess is very confusing when you first come across it:

go to the root of your website with your ftp client, see if there is a file called: .htaccess

If there is one, download it to your computer.

Open it up in a text editing application, your html editor is fine (be careful if you use something like ms notepad though, since it always tries to save things as .txt if you don't force it not to.

Look for the line:

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

If it's not there, add that line under the last current line, hit enter to create a line break, save the file as .htaccess, upload it back to your root directory.

If there was no .htaccess file, create one with just that one line, hit enter to create the linebreak, save it, and upload it.

If your site is running apache, that should do it.

.htaccess files are worth reading about, since they give you a lot of control over many aspects of your site, like creating custom page missing 404 pages for example.

Fryman

7:06 pm on Feb 4, 2004 (gmt 0)

10+ Year Member



Ok, Now I have that file uploaded to my web server... Is there a simple way to test that my html pages will now accept the php script?
Just a few stept away from completing my script instalation, but I want to test that it will work

Thanks again

isitreal

7:09 pm on Feb 4, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



create an html page:

...
<body>
<?php echo 'hello world';?>
</body>
</html>

save it as test.htm, upload it to your root directory, then go to it, you should see a blank page with 'hello world' written on it, that means php is working on htm and html extensions

Fryman

7:20 pm on Feb 4, 2004 (gmt 0)

10+ Year Member



It worked! I was ready to pull my hair out, but you all solved my problem.

Thank you so much, I'll get back to installing my script now.

:)