Change url extension (HTML to PHP) without hurting Google ranking.?

  • Thread starter Thread starter IB noob
  • Start date Start date
I

IB noob

Guest
Hello,

I created a website over a year ago, during which I have managed to get a decent ranking on google for quite a few keywords.

The site is mainly made of HTML files so the URLs mostly end with .html. However, in order to expand it's functionality I'm starting to use PHP but in order to do so on existing pages I need to change them from example.html to example.php...

This creates two problems:

1. Links currently on Google will lead no where.
2. The new PHP pages will not be listed on Google and I will have to work for rankings again.

I've read that 301 and 302 redirects are bad for Google rankings so I won't be using either.

So the question is:

Is there a way in which I can change the file extension without causing either of the above mentioned problems?
Or is there a way for me to add some PHP code into the HTML files and have them function properly?

Thanks in advance.
 
You cannot use php code in HTML files and there is actually a standard method for redirects.

301 Redirect is the answer

If you are hosting on windows use IIS redirect
* In internet services manager, right click on the file or folder you wish to redirect
* Select the radio titled "a redirection to a URL".
* Enter the redirection page
* Check "The exact url entered above" and the "A permanent redirection for this resource"
* Click on 'Apply'

If you are using Linux
Create a .htaccess file with the below code, it will ensure that all requests coming in to domain.com will get redirected to www.domain.com
The .htaccess file needs to be placed in the root directory of your old website (i.e the same directory where your index file is placed)

Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^domain.com [nc]
rewriterule ^(.*)$ http://www.domain.com/$1 [r=301,nc]

Please REPLACE domain.com and www.newdomain.com with your actual domain name.

Note* This .htaccess method of redirection works ONLY on Linux servers having the Apache Mod-Rewrite moduled enabled.
 
This will depend on the web-server your host is using, but I know that at least Apache can be made to accept html as an alias for php, thus treating html-files as if they were php-files. You could always ask your service-provider if this can be done for your site.
 
Back
Top