Latest tutorial: Making a Movieclip face another Movieclip or point on the stage | Ask Tutorial5!
 

Build Your Own Database Driven Website Using PHP & MySQL

SitePoints Best Seller book on scripting.

  • Learn how to install and administer PHP & MySQL on Windows, Linux or Mac

  • Build your very first live Database Driven Website using PHP & MySQL

  • Instantly apply working code examples from the book to your Website


Download the free chapters now!

Mod rewrite PHP to HTML htaccess

(7 votes)
Software - Scripting
Written by DanielRo   
In this tutorial you are going to learn how you can rewrite all your PHP pages to HTML using a simple .htaccess rule for better search engine indexing. This is a basic page.php to page.html htaccess script.
In this tutorial we are providing a script that can only work if you are hosted on a Linux server. If you are not hosted on Linux then you should checkout the popular Bluehost.com hosting they have been providing hosting solutions to thousands of business and personal web sites since 1996.

There is a myth saying that search engines will better index your site if your pages are displayed like static HTML.

Personally I don't believe it actually makes a difference for search engines if your pages are either PHP or HTML but in the long run it can increase your sites security.

The language your site is coded in is irrelevant and also a security vulnerability, if people know what language your site is coded in, they'll more easily be able to exploit any code vulnerabilities.

Say for example you have a website and a menu witch is dynamically built using PHP, you could only use it on PHP pages.

Example:
You have menu.php and all the pages of your site: index.php, services.php, portofolio.php, contact.php

Using the following script you will be able to access the contents of all your pages using a HTML extension.


The .htaccess file starts here


RewriteEngine on
RewriteBase /
RewriteRule ^(.*)\.html$ $1.php [L]


One would also have to change all the links trough out the website from the PHP extension to HTML.

Your visitors can now access the contents of services.php using services.html

Using this htaccess basic PHP to HTML rewrite rule you can present PHP files as HTML.


Subscribe now via RSS feed and get all the new tutorials


Do you need more help? Ask now!
 

busy
Last Updated ( Saturday, 09 February 2008 )