htaccess的重写规则重定向的URL包含具体参数

编程入门 行业动态 更新时间:2024-10-21 14:43:29
本文介绍了htaccess的重写规则重定向的URL包含具体参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我已经看到了关于类似请求的几个问题,但是,我并不想重定向到一个自定义制作的URL。我只是想获得那些已与通用网址,并将其重定向到一个登陆页面。

I've seen several questions regarding similar requests, however, I'm not trying to redirect to a custom crafted URL. I just want to take common URLs that have been linked to and redirect them to a landing page.

例如,我要赶上像下面特定的URL,但仅此网址:

For example, I want to catch a specific URL like the following, but only this URL:

example/forum/viewtopic.php? F = 12& T公司= 345

...并重定向到:

example/landing-page.html

我有一个不再存在的几个环节,所以我会加入4或5重定向到更多有用的网页,因为他们目前正在打404的。

I have a few links which no longer exist, so I'll be adding 4 or 5 redirects to more useful pages since they're currently hitting 404's.

在此先感谢!

推荐答案

添加到您的htaccess文件在你的文档根目录:

Add this to your htaccess file in your document root:

RewriteCond %{QUERY_STRING} ^f=12&t=345$ RewriteRule ^forum/viewtopic.php$ /landing-page.html [R=301]

从本质上讲要匹配这个查询字符串的RewriteCond 和URI中的重写规则。

更多推荐

htaccess的重写规则重定向的URL包含具体参数

本文发布于:2023-11-01 18:17:16,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1550059.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:重写   重定向   规则   参数   htaccess

发布评论

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

>www.elefans.com

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