htaccess的重写规则重定向的URL包含具体参数 [英] .htaccess RewriteRule to redirect url's containing specific parameters
问题描述
我已经看到了关于类似请求的几个问题,但是,我并不想重定向到一个自定义制作的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:
http://example.com/forum/viewtopic.php? F = 12& T公司= 345
...并重定向到:
http://example.com/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包含具体参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!