Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

i am working for a site,which is in php.....i want to rewrite url

e.g www.3idiots.co.in/stories.php?id=17

if i want to rewrite it as

www.3idiots.co.in/stories/17.html

can any one tell me the code for this to write in .htaccess file.?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
281 views
Welcome To Ask or Share your Answers For Others

1 Answer

I'm assuming you're using Apache with mod_rewrite. Something like

RewriteEngine On
RewriteRule ^/stories/([0-9]+).html /stories.php?id=$1

should do the trick. Of course you'll need to make sure that RewriteRule is allowed in that directory. See this wiki page for more information.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...