This post will cover a couple key features and what code we used to dynamically change our .php extensions to read .html while keeping the same filename so there is no need to rename files. This is very easy process and takes a couple easy to follow steps, we'll start out with some of the benefits of using this mod and then give you a breakdown of server settings you will want to check before you get started.
Benefits of rewriting your URL
Plain and simple, easier to read, the search engines will like your pages better and you can hide what language your website it coded in. A good example is when a search engine visits the dynamic url like product.php?id=5 it does not give much importance to that URL as search engine sees “?” sign treat it as a url which keeps on changing. so we’re converting the dynamic URL like the product.php?id=5 to static url format like product-5.html.
Required for URL rewriting
Directions and examples
After you have checked to make sure your server supports all the the requirements you will need to create a file called .htaccess in the root of your website, this can easily be done on the ftp side of the site. If you use windows you might have an issue creating a .htaccess file due to the fact that microsoft hates linux and knows you're trying to create a file of the sort. Creating it server side via ftp then downloading the file to your desktop might be the best route if you are having issues creating the file. After you create the file add the following code to your .htaccess file:
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.*).html$ $1.php [nc]
The above example will rewrite the test.php to test.html i.e when a URL like http://localhost/test.html is called in address bar it calls the file test.php. As you can see the regular expression in the first part of the RewriteRule command and $1 represents the first regular expression of the part of the RewriteRule and [nc] means not case sensitive.
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^product-([0-9]+).html$ products.php?id=$1
The above example will rewrite the product.php?id=5 to product-5.html i.e when a URL like http://localhost/product-5.html calls product.php?id=5 automatically.
1 2
Thanks for good information that comes out to
read.
reply
Great journey and experience!
reply
Great article, i
hope can know much information About it!
reply
the valuable ideas u provided do help our team's research for my group, appreaciate that.
- Lucas
reply
I just sent this post to a bunch of my friends as I agree with most of what you’re saying here and the way you’ve presented it is awesome.
reply
I’ve been visiting your blog for a while now and I always find a gem in your new posts. Thanks for sharing.
reply
1 2
Our main place of business and mailing address: