Apache and Rewrite url problem
i have some problems with url rewrite
i need trasform that url
News/?a=shownews&id=53
to
index.开发者_如何学Gophp?m=News&a=shownews&id=53
i tried to make it:
RewriteRule ^([A-Za-z0-9_]+)/\?(.+?)$ index.php?m=$1&$2 [R]
but it dosen't work, could do you help me to fix it?
EDIT: I take that back - apparently it is possible to do this in your case
RewriteRule ^(.+)/$ index.php?m=$1 [QSA]
Apache cannot use $_GET parameters to build the new URL ; you'll have to change the structure of the URL.
From Apache's documentation:
By default, the query string is passed through unchanged. You can, however, create URLs in the substitution string containing a query string part. Simply use a question mark inside the substitution string to indicate that the following text should be re-injected into the query string. When you want to erase an existing query string, end the substitution string with just a question mark. To combine new and old query strings, use the [QSA] flag.
Using the [QSA] flag you can rebiuld your URL as you have, and the existing query string parameters will be appended, or passed through.
Hope this helps.
精彩评论