PDA

View Full Version : Renaming files from .htm to .php



cppgenius
01-08-2007, 03:23 PM
I want to convert one of my sites into a dynamic site with PHP because there is a lot of repetitive code on each page that I would like to put in a single php script to make the maintenance of the site easier.

The problem is, the site is almost a year old and a lot of SEO work has been done on this site. Its traffic can still be greatly increased, but I do not want to loose the traffic I already get from the search engines.

I have not access to the .htaccess file so I am forced to rename all my pages to php to have the code parsed by the server. Because of this I also can't do 301 redirects from a file with an htm/html extension.

So the best way to do this is with a 0-second meta refresh, something that is supported by most browsers and accepted by most Search Engines as something similar to a 301 redirect. I know you need to stay away from JavaScript redirects, another reason why I switched to PHP to have more server side scripting done opposed to faulty client-side scripting.

I have prepared all the html files with the proper meta refreshes, but I would like to know how long should I keep these "place holders" for my old pages on my server. The search engines may re-index my site and hopefully transfer the PageRank to the new pages, but what about all the inbound links from other sites (even some I may not be aware off) is it wise to keep these redirecting pages for an infinite time on my server.

Thanks I appreciate the help.

adbart
01-09-2007, 04:19 AM
Meta Refresh URL Redirect is an example of a meta refresh URL redirect. The code is quite simple.
<meta http-equiv="refresh" content="8;url=http://www.seocompany.ca/index.html" />
Meta tag refresh is known to not be very search engine friendly and is consider spammy because of its misuse. If you keep it up around 8 seconds it is said it is ok. This method displays the new page that the refresh points to.
The thing about leaving the redirect high (8 secs or so) sounds like common sense.

I'd consider putting it at 10 or something. Also, on each original .htm page, put a link to the new page on it, e.g:




<center>This page has moved.

Click here to go to the new page. (newpage.php)</center>

Webnauts
01-09-2007, 09:48 AM
Never use meta refresh! Too risky!

Do that with PH. See here how simple that is: http://php.about.com/od/learnphp/ht/phpredirection.htm

cppgenius
01-09-2007, 01:24 PM
adbart I used exactly the method you described but only with 0-second refresh. I will make it 10 seconds like you suggested. Luckily I have not uploaded any files yet so no damage done. Good thing I asked for advice first.

Webnauts thanks for the page on PHP redirection. Unfortunately my web hosts only allow PHP parsing in .php files so no parsing is done in .htm files and like I said I have no access to the .htaccess file so I cannot configure the PHP settings on the server.

But the link you provided was a lifesaver with a page of another site I had redirection problems with. The redirection worked on my local Apache server but failed once I uploaded it too my server. I never knew that the PHP code should be the only code in the file with no text to be sent to the browser before the PHP script. The redirection started working once I removed the other text from the file.

I hit two flies with one question. Thanks guys!

I just wonder why the redirection succeeded on my local server, which setting allows a mixture of HTML and the 301 PHP code in the same file? Any ideas?

mikesmith76
01-09-2007, 02:25 PM
You can set headers and have html in the same php file, but all calls to header() MUST be made before ANY html is outputted, or you will receive an error to that effect. If you didn't get an error on your local server you must have error reporting off (or very low)

Serrbiz
01-09-2007, 05:57 PM
A meta refresh is an ultra dangerous method to use. Even though it sounds like you 100% ethical in you purpose, the spammers used that tag to excess and it just to much of a risk.

Google says this about redirects.

Don't employ cloaking or sneaky redirects.

.htaccess with a 301 code is the best. If your server doesn't allow this, then switch servers. You shouldn't have to spend more $29 a month for quality hosting with root level and .htaccess.

DrTandem1
01-09-2007, 06:21 PM
Some hosts allow a simple line of code in the .htaccess file that will treat each .html page as if it were PHP. You can then keep the page files as whatever.htm and still have the PHP function. Something like this:

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

Are you sure you don't have access to the .htaccess file? If not, maybe change hosts to one that will work.

steve0
01-09-2007, 06:29 PM
If there is a lot of repetitive code, and the site is optimized..

How about server side includes?

Andy Beard
01-10-2007, 12:05 AM
I totally agree with DrTandem

If you really don't have the ability to modify your .htaccess, it is time to find a new host.

There shouldn't be a need to change your file names and lots of scripts require htaccess to provide user friendly URLs.

caromero1965
01-10-2007, 12:41 AM
I'm with Andy on this one-- if you're sure you don't have access to the .htaccess file (or can't create one for each directory), then... forget about these guys, they're not worth hosting with anyway. Can you say who they are? It really sounds like they're giving you a raw deal.

I'm using cheap hosting at 1and1.com and finding it perfectly serviceable for running wordpress blogs (though a bit sluggish at time, in the $10 a month plan I'm using). A really good host for Linux/Apache stuff, by all accounts (though I haven't tried them) is Media Temple (mediatemple.net). Have a look at both of these. I'm sure plenty of people here can recommend others as well.

ddwebguru
01-10-2007, 06:53 AM
but it's not the proper method - i mean to change server, i know yahoo server do not give access the .htaccess file, so what we have to do??

ddwebguru
01-10-2007, 06:59 AM
hi
there is a great discussion about redirection. hope it may help you >
http://www.webmasterworld.com/apache/3208525.htm

Andy Beard
01-10-2007, 07:18 AM
ddwebguru if they don't give access, it is what customers do, take their money elsewhere.

ddwebguru
01-10-2007, 08:00 AM
yea i am agree but if we get some other way it will be much better

Andy Beard
01-10-2007, 08:16 AM
Your sig suggests you are an SEO. If you are working for a client who is using hosting that doesn't allow the use of .htaccess, your first task is to move them to a host that does allow it.

There are so many uses for .htaccess and mod_rewrite as an SEO that it should be a requirement for you to undertake the work.

texxs
01-10-2007, 12:38 PM
try SSI includes, you don't have the change the file name then.

edhan
01-11-2007, 12:21 AM
Being able to access .htaccess and mod-rewrite is the basic function that you should be able to do so. If not then it will be better finding about hosting service that allows you to do so.