Change .php to .html using .htaccess or httpd.conf
It is common that when a site already has so many html pages, it is converted to php/asp to make it database driven so it’ll be easier to manage. But the problem is that some pages are already bookmarked, linked by other sites, and have a good Google Page Ranking.
If a site is converted to php, the html page is lost and you will be seeing a lot of 404 reposts on your stats. There are many ways to solve this problem, but for this article we will be manipulating the server settings to allow php database driven sites to appear as html, thus preventing any error 404 on your site.
http://alfredo.palconit.com/archives/php-to-html-using-htaccess-httpdconf.html
is different from
http://alfredo.palconit.com/archives/php-to-html-using-htaccess-httpdconf.php
Here are the basics. When you save a file as .php the server will see it as a php file. When you save a file as .html, the server will treat it as a regular html file. But when you write php codes on a file and save it as .html, the server will still treat it as an html file and the php code will appear in the html source code, and php functions wont work, unlike when you save it as .php, the php codes will not appear in the browser and the php code will function.
To make your .php file to appear as .html on a browser, you will need to change either the http.conf settings of your Apache Server or create/update your .htaccess file if you don’t have access to the Apache Server configuration file.
Here is how to update your httpd.conf:
AddType application/x-httpd-php .php .html
Notice the ‘.html’ added in the line. This means the server will see .html files as .php.
If you don’t have access to httpd.conf, make the changes in .htaccess by adding this line of code:
AddType application/x-httpd-php .php .html
Make use you save it as .htaccess (notice the ‘.’ before .htaccess) and must be located on the folder where your pages are.
Disclaimer: I haven’t actually tried this one but maybe this will work. I am not responsible if your PC will catch fire if you make these changes. Please post a comment if you’ve tried it to work. :)
Update: Here is what I used on one of my client’s site wanting a php file to have an .html extension.
RewriteEngine on
RewriteRule (.*)\.html$ index.php?page=$1
the effect would be
http://www.palconit.com/index.php?page=test
can now be viewed as
http://www.palconit.com/test.htmlÂ
Check my other posts:
- SEO friendly redirect domain.com to www.domain.com
Last week, I noticed that there is a PageRank difference... - About Phishing Sites
After years of working on different servers for several clients... - How to display javascript on top of flash
Ever had that experience where your javascript is shown behind... - Why is on page optimization important?
There are two ways of optimizing a website: on-page and... - Withdraw PayPal to Philippine Banks
1st Update: I can’t add my bank right now, I... - Website Baker
Just got an email from a client talking about using... - New Job as an SEO Specialist
Tonight, March 10 is my official start date as an... - How to do an effective off page optimization
There are various factors that search engines consider before they... - How to watch iWanTV on a Mac
If you are a BayanTel and SkyBroadband subscriber and you... - Blogging on hot topics can exponentially boost your traffic
A Palconit Network member site, L’Ange Bleu, is currently enjoying...
3 Responses to “ Change .php to .html using .htaccess or httpd.conf ”
The problem with the AddType solution is, it will invoke the php interpreter on all .html files. That\’s probably not a price you want to pay.
It\’s probably not that expensive since there probably aren\’t any PHP tags in the static .html files. But it\’s still a cost. PHP startup is not free.
It might be better to use mod_rewrite to target individual URLs. This way, if you receive a request for your well_known_page.html, mod_rewrite will rewrite it to call the .php instead. Alternatively, you could have your .html redirect to the .php (you get the benefit of the good rating, plus, possibly, the search engine will start to give the .php a good rating too). I\’d probably go with mod_rewrite though.
This tag is vcery useful to me
tere ma ki chut bah key land bhosri key javascipt mey validation nahi laga sakta tha .
Leave a Reply