HomeTips & TricksWeb DesigningHow to do URL Re-writing in PHP with Simple htaccess Modify

How to do URL Re-writing in PHP with Simple htaccess Modify

URL re-writing means reformatting the webpage URL and turn your long dynamic URL into a shorter and static one.It gives  a better representation of your URLs.To accept GET arguments through a URL we need to modify the .htaccess file in root website folder.Which helps to convert your Page Urls into well organized form.e.g.

http://techniblogic.com/?tag=SEO

to

http://techniblogic.com/tag/SEO

Generally this is nothing more than enabling the mod_rewrite module (you likely already have it enabled with your host), and then adding a .htaccess file into your web-directory. mod_rewrite is used for rewriting a URL at the server level, giving the user output for that final page.

There are two ways of Respresention of your URL ,they are :-

Type 1 – Single Page URL

Generated URL http://techniblogic.com-tag-seo.htm
Example URL http://techniblogic.com-tag-(Any Value).htm

Create a .htaccess file with the code below
The .htaccess file needs to be placed in techniblogic.com

Options +FollowSymLinks
RewriteEngine on
RewriteRule -tag-(.*)\.htm$ ?tag=$1

Type 2 – Directory Type URL

Generated URL http://techniblogic.com/tag/seo/
Example URL http://techniblogic.com/tag/(Any Value)/

Create a .htaccess file with the code below
The .htaccess file needs to be placed in techniblogic.com

Options +FollowSymLinks
RewriteEngine on
RewriteRule /tag/(.*)/ ?tag=$1
RewriteRule /tag/(.*) ?tag=$1

You can use SIMPLE .htaccess URL Rewriting Tool for Regenerate URL rewrite rules for your Apache .htaccess file. It takes a list of dynamic URLs and converts them into SEO friendly static URLs.

  1. Open URL Rewriting Tool Pagenimtools-htaccess URL Rewriting Tool
  2. Enter the Query URL in the Input Box
  3. It will Generate 2 Formats of URL Representations.Choose the method you like.
    nimtools-htaccess URL Rewriting Tool type 1
    Type 1 – Single Page URL
    nimtools-htaccess URL Rewriting Tool type 2
    Type 2 – Directory Type URL

    This tool help you to easily create code for your .htaccess file,you just have to copy and paste that created.

  4. Done

URL Rewriting FREE Tool

Hope this will help you and solve your problem 🙂

Techniblogic
Techniblogichttps://techniblogic.com/
Get Top Technology Reviews and Updates . Techniblogic provide you the Top Tech Reviews of Latest gadgets as well as Tech Guide.

Latest Articles

Exclusive Article

How to Find Instagram Trending Reels Song [4 Only Ways]

Looking for Instagram Trending Reels Song to create your own trending Instagram reels? Don't worry! Here are the best ways to find Instagram Trending...

LEAVE A REPLY

Please enter your comment!
Please enter your name here