Home » Php » php – how to hide id from the url and make it clean url my directory of .htaccess file is /home/evidhya/public_html/tutorials/.htaccess

php – how to hide id from the url and make it clean url my directory of .htaccess file is /home/evidhya/public_html/tutorials/.htaccess

Posted by: admin February 25, 2020 Leave a comment

Questions:

I have following url i would like to hide id and make it clean url

https://www.evidhya.com/tutorials/tutorials.php?qid=569/AJAX/Introduction

clean url should be like below url
https://www.evidhya.com/tutorials/AJAX/Introduction

how can i achieve this

How to&Answers:

Well, it seems the id is needed to determine the resulting url.
I would do this:

RewriteEngine on
RewriteRule (\d+)/(\w+)/(\w+) tutorials.php?qid=$1/$2/$3 [L]

and place this rule in tutorials/.htaccess.

And when someone goes to https://www.evidhya.com/tutorials/569/AJAX/Introduction it should load https://www.evidhya.com/tutorials/tutorials.php?qid=569/AJAX/Introduction