apache - RewriteRule for nicer URL -


i want redirect queries

www.example.com/mysite/post/3/title-of-the-post 

to

www.example.com/mysite/display.php?id=3 

by setting .htaccess file @ root of www.example.com/mysite/. tried :

.htaccess file ---------------  rewriteengine on rewriterule ^post/([0-9]+)/* index.php?id=$1 [l]  

why doesn't work? how set rewriterule in situation? need add more lines single line in .htaccess ?

you don't need * (which should .*) @ end because you're not ending expression $. can instead:

rewriterule ^post/([0-9]+)/ index.php?id=$1 [l] 

if want close expression, use this:

rewriterule ^post/([0-9]+)/.*$ index.php?id=$1 [l] 

Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -