Mod rewrite PHP to HTML htaccess |
| 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.
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 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.
written by rahul111 , November 13, 2008
http://localhost/project/index...egory_id=5 rewrite url : http://localhost/project/index.php/category i use xampp server how can do...
written by occasional Idea , November 26, 2008
How to change dynamic path to .htm or .html path e.g. http://www.domain.com/category.php?cat=1 where cat=1 is "system" convert to http://www.domain.com/system.htm
written by Paul Hutchinson , December 12, 2008
how can i do somthing like this for images? RewriteRule ^(.*).png$ images/$1.png [L] but theres a problem. when trying to view a image it sets of a never ending loop. How can i solve this Thankyou Paul
written by Hitesh Patil , January 05, 2009
I used it. It works but when there is really .htm file and when i access it then it give [file name].php is missing. i mean 404 error. I want that if .htm file is present then it should not seek .php
written by Brandon , January 08, 2009
I did this on my index, which I didn't really know what this did. Now it's asking me to download my index page of my website. How can I take this off, because deleting the .htaccess file didn't turn it off. I hope you reply, because I am so lost here.
written by Amit Sidhpura , July 24, 2009
Thanks man, after half an hour of search this is the page where i found the required solution. Thanks again..Keep it up..
written by AndrewAM , September 29, 2009
I notice none of the questions have been answered? I have been trying for a few weeks to rewrite php file extensions to html and have been failing, I've used exactly the same code posted in so many forums but no success? Any ideas? Andrew
written by Natalya Shirinova , February 02, 2010
how to change from http://www.example.com/?cat=1 to http://www.example.com/Category/ plz help, thanks
written by Mayur Shah , February 03, 2010
hi Options FollowSymlinks RewriteBase / RewriteRule ^(.*).html $1.php This is useful when you need to convert from PHP to html extensions same time if you need to pass more parameter with different php file than need to write something like this Options FollowSymlinks RewriteBase / RewriteRule (.*).htm$ /page.php?file=$1 We had done with this like you can see both options is working fine http://www.addonsolutions.com hire php developer . html There are more options too Thanks
written by hang dara , April 02, 2010
Hello I want to know about htaccess convert php to html and how i can provide my website to www.google.com search engine farster?
written by asdsd , May 11, 2010
I notice none of the questions have been answered? I have been trying for a few weeks to rewrite php file extensions to html and have been failing, I've used exactly the same code posted in so many forums but no success? Any ideas? Andrew
written by Tutorials99 , May 26, 2010
Just brilliant. Awesome tutorial. keep it up i found another site having Fantastic Page Rank Professional tutorials see link below tutorials99
written by Lissa , August 14, 2010
I need the redirection to be auomatic, not manual. Pls ..Any suggestions
written by Sunil Sharma , August 15, 2010
Hi all, I have used the code which is suggested in the post but nothing happened. Website name: www.2d3dcreations.com Hosting Provider: hostgator If I use given below code then it shows http://www.2d3dcreations.com/aboutus.php.html like this. It does not remove .php extension from the url. Options FollowSymLinks RewriteEngine on RewriteCond %{REQUEST_URI} ^(.*).php$ RewriteRule ^(.*) /$1.html [R=301,L] If I post given below code then nothing happen. Options FollowSymLinks RewriteEngine on RewriteBase / RewriteRule ^(.*).html$ $1.php [L] Please help me on this issue. Regards, Do you need more help? Ask now!
|
|
| Last Updated ( Tuesday, 29 July 2008 ) | |