Rewrite changing Url
I'd like to use apaches mod_rewrite to rewrite my url's. Normally, that i could do that, but i think is a special case. The content on the page depends on the url parameters, but is also capable of altering those parameters, and thus gaining new content without refreshing. The same parameters would always give the same result, however.
My url currently looks like this:
http://example.com/#?div1=1&div2=5
I would like to be able to use a neat, clean url, like http://example.com/nameofarticle. Does using mod_rewrite prevent开发者_开发知识库 changing a parameter that is "hidden" beneath such a url? And if not, how can i use mod_rewrite in order to allow me to keep working like this?
Thanks in advance!
I think you need the RewriteCond %{QUERY_STRING}
before your RewriteRule. Something like:
RewriteCond %{QUERY_STRING} div1=(.*)&
Then you can access the bracketed values in the RewriteRule
with %1
... Just as you'd use $1
for bracketed values in the RewriteRule itself.
You may also want to be looking at the RewriteRule flag [QSA]
. Quoting the mod_rewrite
docs:
- 'qsappend|QSA' (query string append)
This flag forces the rewrite engine to append a query string part of the substitution string to the existing string, instead of replacing it. Use this when you want to add more data to the query string via a rewrite rule.
精彩评论