.htaccess - 如何重定向 URL 中带有问号的旧页面?

标签 .htaccess redirect

我已经在 stackoverflow 和其他网站上阅读了有关 htaccess 重定向和重写的内容,并了解了如何重定向简单的页面和目录,但还剩下大约 30 个链接我无法重定向。原因似乎是因为它们在链接的 URL 中包含“?”。我已经尝试过发布的解决方案,但我无法充分理解它们以取得成功。

这些工作:

Redirect /Corpfleet.php     htp://www.marketyourcar.cm/wraps.php
Redirect /drivers.php       htp://www.marketyourcar.cm/drivers.php
Redirect /galleries.php     htp://www.marketyourcar.cm/galleries.php

这些不起作用:

Redirect /ad.php?View=FAQ       htp://www.marketyourcar.cm/advertiser-faqs.php
Redirect /ad.php?View=gallery   htp://www.marketyourcar.cm/galleries.php
Redirect /ad.php?View=Materials htp://www.marketyourcar.cm/products-services.php

是的,我知道上面的 URL 是 htp 和 .cm - 我必须破坏它才能以我的低声誉级别发布这篇文章。

如果有人可以提供帮助,我将不胜感激。 谢谢

最佳答案

如果您想从以下位置重定向:

site.com/index.php?blabla=1&id=32

site.com/contact.html

然后使用:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{QUERY_STRING} blabla=1&id=32
RewriteRule ^(.*)$ http://www.site.com/contact.html? [R=301,L]
</IfModule>

关于.htaccess - 如何重定向 URL 中带有问号的旧页面?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14492735/

相关文章:

php - 如何解决rest api中的CORS预检错误

Apache 重写和重定向

redirect - 如何为301重定向的用户在新网站上弹出?

android - Httpclient 重定向处理程序

ruby-on-rails - 重定向后的验证消息

.htaccess - 将 index.php 重定向到 .htaccess 中的根目录

php - 使用 .htaccess 在 php 中实现干净的 url

.htaccess - 如何编写我的 rewriterule 以便我可以拥有友好的 url

禁止 Python HTTP 重定向请求

php - htAccess 重定向除 Assets 文件夹之外的所有 .php