使用.htaccess隐藏变量 [英] Use .htaccess to hide variables

查看:64
本文介绍了使用.htaccess隐藏变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,所以在IIS中这样做相对简单,但是我试图确保所有内容也都在Apache上运行。

Ok, so this is relatively straightforward to do in IIS, however I am trying to make sure everything runs on Apache too.

我需要转向 http://domain.com/?page=about (其中 page 是变量,而 about 是信息)到 http://domain.com/about

I need to turn http://domain.com/?page=about (where page is the variable and about is the information) into http://domain.com/about

希望所有链接都被自动更改(因此,如果链接用于?page = about ,则它将更改为 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.

推荐答案


但是,我希望它将/?page = $ 1的任何内容重定向到/ $ 1,以便domain.com/?page=about变成domain.com/about

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]

这篇关于使用.htaccess隐藏变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆