.htaccess rewrite “/book.php?id=1234” to “/book/1234”

这一生的挚爱 提交于 2019-11-27 05:41:18

Your RewriteRule as written appears to be trying to do opposite of what your question headline is saying. You say that you want htaccess rewrite /book.php?id=1234 to /book/1234, but your RewriteRule:

RewriteRule ^(.*)$ /book.php?url=$1 [L]

Is adding a query string parameter.

The RewriteRule below will rewrite rewrite /book.php?id=1234 to /book/1234

RewriteCond %{QUERY_STRING} ^id=([0-9]*)$
RewriteRule ^book\.php$ /book/%1? [L]

Also, if you really wish to go the other way, i.e. rewrite /book/1234 to /book.php?id=1234 the following should do that:

RewriteRule ^book/(.*)$ /book.php?id=$1 [L]
suraj

try this!

# in htaccess file write this
RewriteEngine on 

RewriteRule ^book/([0-9]+) book.php?id=$i

# and in you html or php file call

book.php?id=$i 

page by

book/$i 

you are done.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!