Use .htaccess to hide variables

时间秒杀一切 提交于 2019-12-11 03:46:12

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!