使用.htaccess隐藏变量

编程入门 行业动态 更新时间:2024-10-25 10:26:50
本文介绍了使用.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.

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

I need to turn domain/?page=about (where page is the variable and about is the information) into domain/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/?page=about变成domain/about

However, I want it to redirect anything that is /?page=$1 to just /$1 such that domain/?page=about turns into domain/about

然后您需要添加以下内容:

Then you'll need to add this:

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /\?page=([^&\ ]+) RewriteRule ^/?$ /%1? [L,R=301]

更多推荐

使用.htaccess隐藏变量

本文发布于:2023-10-31 18:37:27,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1546936.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:变量   htaccess

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!