如何在众多的ID htaccess的PHP文件rediect [英] How to rediect in htaccess .php file with many IDs

查看:292
本文介绍了如何在众多的ID htaccess的PHP文件rediect的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我删除了很多老网址:

I have many old URLs that I deleted:

viewnews.php?id=1357570020
viewnews.php?id=1565656889
viewnews.php?id=7877878768
viewnews.php?id=7876876876

我有这样一个一千网址这样。我想所有这些重定向到我的主页的网址。他们不存在了。

I have like a thousand URLs like that. I want all those URLs redirected to my main page. They do not exist anymore.

我要当有人进入这里mysite.com/viewnews.php?id=(ANY~~V ID)自动转发到www.mysite.com

I want when someone goes to mysite.com/viewnews.php?id=(ANY ID HERE) to automatically forward to www.mysite.com

我如何做到这一点的htaccess的?我已经尝试了很多东西。

How do I do that in htaccess? I have tried many things.

Redirect 301 /viewnews.php(.*)$ http://www.mysite.com/

任何帮助将是很大的AP preciated。

Any help would be greatly appreciated.

感谢。

推荐答案

使用mod_rewrite你可以用下面的code来处理这个任务:

Using mod_rewrite you can use following code to handle this task:

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+viewnews\.php\?id=[^\s]+ [NC]
RewriteRule ^ http://%{HTTP_HOST}? [R=301,L]

这篇关于如何在众多的ID htaccess的PHP文件rediect的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆