I am using Apache .htaccess to do redi开发者_Go百科rection:
RedirectMatch "^/mysubpage/?" http://domain.com/page [R=301,L]
Link: http://domain.com/mysubpage
But when the page loads, the link changes to: http://domain.com/page/?uri=/mysubpage/
Why does it append the "?uri" query string?
I think it's because of the ? in your redirect match regex, but I'm not exactly sure what you're trying to do. If you are wanting to capture the glob following the last slash (what is appearing in your uri= substring) and use that as part of a different URI then what you want is something like this
RedirectMatch "^/mysubpage/(.*)" http://domain.com/page/$1 [R=301,L]
That will take any request to http://domain.com/mysubpage/alpha.php
and redirect it permanently to http://domain.com/page/alpha.php
. If on the other hand you don't care about what is after the slash in the request to mysubpage then you can do something like this:
RedirectMatch "^/mysubpage/.*" http://domain.com/page [R=301,L]
That will drop the rest of the request and redirect to http://domain.com/page
.
HTH
Most likely your http://domain.com/subpage is already a rewritten URL?!
Try this:
RedirectMatch "^/mysubpage/(.*)" http://domain.com/page/$1? [R=301,L]
The Questionmark at the end of your redirect-destination is to prevent appending the old querystring to it (which is default behaviour).
精彩评论