问题
Ok, so this is relatively straightforward to do in IIS, however I am trying to make sure everything runs on Apache too.
I need to turn http://domain.com/?page=about
(where page
is the variable and about
is the information) into http://domain.com/about
I also want all links to automatically be changed (so if the link is for ?page=about
it gets changed to about
.)
This is probably simpler than I am making it but for the life of me I can't figure it out.
回答1:
However, I want it to redirect anything that is /?page=$1 to just /$1 such that domain.com/?page=about turns into domain.com/about
Then you'll need to add this:
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /\?page=([^&\ ]+)
RewriteRule ^/?$ /%1? [L,R=301]
来源:https://stackoverflow.com/questions/13712117/use-htaccess-to-hide-variables