如何在众多的ID htaccess的PHP文件rediect文件、在众多、ID、htaccess

2023-09-02 11:28:00 作者:如歌澈婉颜

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

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]