.htaccess

How to make SEO friendly url using htaccess

In previous tutorial we learned about what is .htaccess. In this tutorial I will explain how to make SEO friendly url using htaccess.
Ex 1 :
https://phpgurukul.com/books.php?bookName=php  using  htaccess  url will be written like this https://phpgurukul.com/php
You can do this using code given below in htaccess file :

RewriteEngine On
RewriteRule ^([^/\.]+)/?$ books.php?bookName=$1

Ex 2 :
https://phpgurukul.com/books.php?bookName=php&&chapter=array   using  htaccess  url will be written like
https://phpgurukul.com/php/array
You can get by using code in htaccess file given below :

RewriteEngine On
RewriteRule ^([^/\.]+)/([^/\.]+)?$ books.php?bookName=$1&chapter=$2

Ex 3 :
https://phpgurukul.com/books.php?bookName=2&&chapter=5 using  htaccess  url will be written like
https://phpgurukul.com/php/2/array/5
You can get by using code in htaccess file given below :

RewriteEngine on
RewriteRule product/catName/(.*)/bookName/(.*)/books.php?bookName=$1&chapter=$2

we can handle this url in other way like this https://phpgurukul.com/books-php-2-array-5.html

RewriteEngine on
RewriteRule product-catName-(.*)-bookName-(.*)\.html$ books.php?bookName=$1&chapter=$2


Recommended Tutorials for you


Tags

Anuj kumar

This is Anuj Kumar. I’m a professional web developer with 5+ years of experience. I write blogs in my free time. I love to learn new technologies and share with others. I founded PHPGurukul in September 2015. The main aim of this website to provide PHP, Jquery, MySQL, PHP Oops and other web development tutorials. .

One Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Back to top button
Close
Close

Adblock Detected

Please disable your ad blocker! This site is supported by the advertisement Please disable your ad blocker to support us!!!