Forum Moderators: phranque

Message Too Old, No Replies

Changing my pages from .html to .php

What will happen to my search engine listings?

         

seamus

8:07 pm on Sep 26, 2005 (gmt 0)

10+ Year Member



I am considering changing all my pages to the .php extension so that I can use php includes to put a common header and footer on each page.

I don’t think that this should affect the traffic to my home page but it will obviously affect hits to other pages ending in .html. I will have to wait for google to index them again before I see the traffic return.

Are there any other implications that I should be aware of?

grandpa

8:17 pm on Sep 26, 2005 (gmt 0)

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



You will want to use Mod_Rewrite to ensure that the PR and backlinks are gracefully handled.

Here's what happens.

You have a page, index.html

You create a new page, index.php

You modify your .htaccess to handle the redirect.
RewriteRule ^index\.html$ http://yourdomain.com/index.php [L]

What the rewrite does is allow you to change your file extension without worry about losing PR or maintaining existing backlinks. Your SE ranking will not be affected.

There are other ways to skin the same cat, this is the method I prefer.

You should continue to refer to your pages as if they were html documents. If page1.html has a link back to the index, link it thusly: http://www.yourdomain.com/index.html

The .htaccess RewriteRule handles everything for you. If you start to reference your new pages as php pages then you are simply adding duplicate content and more pages to your site.

bull

8:43 pm on Sep 26, 2005 (gmt 0)

10+ Year Member



do not rename the files.

Add

AddType application/x-httpd-php .php .htm
in your .htaccess file instead, and the lhtm and .html files will be parsed as PHP

2by4

8:45 pm on Sep 26, 2005 (gmt 0)

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



Don't change your urls at all, just add this one line to your .htaccess file:

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

Make sure to have a linebreak after that line or the server may crash.

An .htaccess file is a simple text file saved as .htaccess

that's dot htaccess

Load this file to your site root directory, the same one your index / homepage file is in. Make sure you transfer it in ascii mode, not binary.

Once you add this line, all your html pages will parse the php and you're set, no changes at all, no mod rewrites, everything is as it was except you now have php processing on all the pages.

grandpa

9:04 pm on Sep 26, 2005 (gmt 0)

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



Just to add, while I've seen this advice (AddType application/x-httpd-php .php .htm) repeatedly, it did not work for me. I'm sure it had something to do with my implementation.

More than one way...

2by4

9:38 pm on Sep 26, 2005 (gmt 0)

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



If your hoster doesn't support .htaccess control over apache, I'd move hosters, I've been setting up way too many sites recently, and all hosters, even the junkiest cutrate bargain basement ones, support this.

Make sure you didn't make a typo or something too, email your hoster and make sure .htaccess works, if not, move on to a new hoster, it's not worth it.

seamus

10:48 pm on Sep 26, 2005 (gmt 0)

10+ Year Member



Thanks guys for all the advice. There is no .htaccess file in my root directory.
Guess I can just make one. I'm not very familiar with a lot of terms so I just wanted to ask first

Make sure to have a linebreak after that line or the server may crash.

What’s a linebreak

2by4

10:51 pm on Sep 26, 2005 (gmt 0)

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



hit your return key after the end of the line of code I gave you.

Save it as .htaccess

Do not use notepad or wordpad to make this, if you don't have a real text editor, you can get crimson editor for free.

Upload the file to your root directory using an ftp client. Make sure that your ftp client is set to transfer .htaccess files as ascii. If you don't have an ftp client, use filezilla, it's pretty solid, and free.

seamus

5:20 pm on Oct 6, 2005 (gmt 0)

10+ Year Member



Thanks guys for all your help.
It didn’t work at first, but after contacting my host it turns out that I had to use

Action application/x-php /cgi-bin/php
AddHandler application/x-php .html .htm

In the .htaccess file. I guess

There are other ways to skin the same cat

Thanks again guys, this is going to make things so easy. I can edit all my pages before I upload the .htaccess

Shawn Collins

7:59 pm on Nov 2, 2005 (gmt 0)

10+ Year Member



Do not use notepad or wordpad to make this, if you don't have a real text editor, you can get crimson editor for free.

Why not use Notepad to edit .htaccess?

I've always edited .htaccess by clicking "View" in WS_FTP and editing the file in Notepad.

g1smd

9:27 pm on Nov 2, 2005 (gmt 0)

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



Notepad cannot save a file that has no name. The .htaccess file only has an extension as far is it is concerned.

tbear

10:26 pm on Nov 2, 2005 (gmt 0)

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



I use notepad, save it to the server and then rename the file.... ;)

Shawn Collins

10:56 pm on Nov 2, 2005 (gmt 0)

10+ Year Member



Notepad cannot save a file that has no name. The .htaccess file only has an extension as far is it is concerned.

What I've done in the past is to create it on Notepad and then edit the file name in WS-FTP.

And it always opens just fine in Notepad via WS_FTP for me.

2by4

11:05 pm on Nov 2, 2005 (gmt 0)

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



" I use notepad, save it to the server and then rename the file"

I use a real text editor and don't have to pretend. Why use a total piece of garbage that hasn't been modified since maybe 1996 when you can use the real thing? I fail to see the logic behind this decision, probably because there simply is none.

Notepad can insert special characters at odd instances, unpredictable. It's not a real code editor, why use it? Real ones are available for free. Do yourselves a favor, use quality tools. Using notepad is like working on a car with a pipe wrench. It's your right to do that, but why? There is no reason except stubborness that I can see. Anyway, each to their own, poor quality or high quality tools, your choice.

g1smd

11:20 pm on Nov 2, 2005 (gmt 0)

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



At least WordPad does have wordwrap, undo, find and replace, etc. Notepad is far too basic.

At the moment I am liking PSPad.

Shawn Collins

11:30 pm on Nov 2, 2005 (gmt 0)

10+ Year Member



I still code HTML by hand, too - perhaps I should be drawn and quartered.

tbear

12:00 am on Nov 3, 2005 (gmt 0)

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



There is no reason except stubborness that I can see.

LOL, Actually, I use Arachnophilia 4 (ocasionally notepad2) out of stubbornness :) But, I don't feel that strong about it!
The important bit was changing the file name.

Garbage is a bit strong, don't you think? And surely it is a real text editor, but maybe not an HTML text editor, but anyway, let's get back on topic.

cws3di

12:18 am on Nov 3, 2005 (gmt 0)

10+ Year Member



Hee Hee

Open up an xterm and use vi

Now, there's a "real" text editor.

:q!

I guess the point I am trying to make is that there are plenty of ways to skin a cat, and your text editor is really personal preference - can't imagine why anyone can fault someone else for their preference in text editor!

moltar

1:11 am on Nov 3, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Notepad cannot save a file that has no name. The .htaccess file only has an extension as far is it is concerned.

It can. You need to specify the filename in quotes when saving it: ".htaccess"

2by4

1:25 am on Nov 3, 2005 (gmt 0)

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



" I still code HTML by hand, too"

Yeah, me too, that's why the comment that using bad tools is so silly.