.htaccess - 从 url 中删除参数

标签 .htaccess redirect

我想删除真实网址后面的参数,然后重定向到没有此参数的相同网址

示例:

我想从中删除参数“r”

http://www.mysite.com/123.html?r=1

并重定向至

http://www.mysite.com/123.html

使用 htaccess 和 301 重定向

谢谢

最佳答案

试试这个:

RewriteRule ^123.html.? 123.html? [L]

请注意第二个网址如何以 ? 结尾,这会删除查询字符串。

来源:http://wiki.apache.org/httpd/RewriteQueryString

关于.htaccess - 从 url 中删除参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4537281/

相关文章:

使用 GET 参数时 Apache Redirect 301 失败,例如 ?blah=

redirect - 301 重定向的 cflocation 与 cfheader

php - 前端 Controller 插件中的 Zend Framework 重定向导致重定向循环

.htaccess URL 重写(sitemap.xml 到 sitemap.php)

wordpress - 将除一个之外的所有 WordPress 页面重定向到 SSL

angularjs - Yii2 + AngularJS

apache - PHP : How to code . htaccess 使其无需编辑即可在本地主机和在线上运行

php - 使用 cookie、javascript 和移动重定向查看完整站点

python - Flask - 将变量从重定向传递到 render_template

python - 在 Django 中基于 IP 地址(国家/地区)重定向域的最佳方法