apache - 将带有参数的 URL 重定向到主页

标签 apache .htaccess redirect

最近我们为一家公司发布了一个新网站,但一些旧链接仍然出现在 Google 网站管理员工具上。

我尝试创建一个重定向,但运气不错,但我想完全删除该参数并将与该结构匹配的所有链接重定向到新主页。

所以这些页面

http://www.example.com/job/view.php?id=142
http://www.example.com/job/view.php?id=3453
http://www.example.com/job/view.php?id=567

将重定向到

http://www.example.com

我使用了这个重定向

RedirectMatch 301 /job/view.php$ http://www.example.com/

工作正常,但生成的网站如下所示:

http://www.example.com/?id=142

最佳答案

你可以试试这个方法

RewriteEngine on
RewriteRule ^job/view\.php$ http://www.example.com/? [R=301,L]

关于apache - 将带有参数的 URL 重定向到主页,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23245274/

相关文章:

apache - 被黑的 Apache Tomcat 服务器有哪些危险?

php - 使用 PHP 的 exec() 函数重定向 shell 命令的输出

.htaccess - 在 htaccess 中使用 <filesMatch> 强制下载

.htaccess - 自动将子域重定向到文件夹路径?

asp.net-mvc - ASP.NET MVC : strange POST behavior

apache - ProxyPassReverse 删除 HTTPS

php - fatal error : Call to undefined function mysqli_connect() while extension are set properly

php 使用 htaccess mod_rewrite 检查 file_exists() 是否存在

wordpress - Wordpress 的所有公共(public)/直接入口点是什么?

java - J2ME HttpConnection 无限重定向