.htaccess - Problems with url rewrite of query string -


i'm trying rewrite urls http://www.url.com/blog/?p=123 http://www.url.com/#blog/123. i've read on things , found can parse query string in rewritecond tried like:

rewritecond %{query_string} ^p=([0-9]*)$ rewriterule ^.*$ /#blog/%0 [ne,r] 

when try urls end being rewritten to:

http://www.url.com/#blog/p=213?p=213

any ideas how properly? also, there way add additional rewritecond checks request_uri contains blog?

you can removing query string entirely:

rewritecond %{query_string} ^p=([0-9]*)$ rewriterule ^.*$ /#blog/%1? [ne,r] 

this should give you:

http://www.url.com/#blog/213 

if want check if url contains term "blog" check:

rewritecond %{request_uri} .*/blog/.* 

it important note not able check "blog" in links http://www.url.com/#blog because, noted patrick, after # not sent server.

see apache wiki on mod_rewrite more information.


Comments