How to change the URL of website with htaccess
PHP

By Admin - June 26, 2017 11:47 pm   1   182   0

Htaccess is Hypertext Access and it is configuration file used by Apache based web servers. It is also helpful for better SEO Every client want their website s url attractive and don't want to display the query strings id's to users. So here s the solution. You can hide any url with htaccess rewrite rules.

Htaccess Rule is basically used for rewrite the url. We can update our website url according to clients requirement with htaccess rewrite rules.

Before URL :

http://www.test-website.com/page.php?category=Casual_Shoes&product_name=Shoe_name&id=1


After URL :

http://www.test-website.com/Casual_Shoes/Shoe_name/1/


Steps :-

  1. Create the new file with name .htaccess in website root folder.
  2. Now Apache Server can read the htaccess rules.
  3. Write this code in .htaccess file.
  4. RewriteEngine must be On in your htaccess file otherwise it will not work.
  5. RewriteEngine On
    #For rewrite url of page.php page
    RewriteRule ^([^/]*)/([^/]*)/([^/]*)/$ /page.php?category=$1&product_name=$2&id=$3 [L]
  6. Save .htaccess file and run your new URL on web browser.






Comment