简体   繁体   English

动态 301 重定向

[英]Dynamic 301 redirects

I'm trying to redirect thousands of ids on a single dynamic PHP and MySQL page.我正在尝试在单个动态 PHP 和 MySQL 页面上重定向数千个 ID。 I work for a news website with around 7,000 articles published and my boss decided to change a 10 year old URL to a new one at the end of last year, crazy right!我在一个发表了大约 7,000 篇文章的新闻网站工作,我的老板在去年底决定将 10 年的 URL 更换为新的,太疯狂了!

I have put in redirects from the old to the new site for standard static pages, but it is the dynamic pages that hold 1000's of article ids that has got me in a pickle.我已经为标准 static 页面添加了从旧站点到新站点的重定向,但是拥有 1000 个文章 ID 的动态页面让我陷入了困境。 I have tirelessly looked for an answer, but to no avail.我不知疲倦地寻找答案,但无济于事。

For example the below redirect is for just one id.例如,以下重定向仅适用于一个 id。 The code below will redirect said specific article.下面的代码将重定向所述特定文章。 Is there a way to redirect all ids on my MySQL database, without hand coding all of them like below, as this would be impractical and an impossible mission?有没有办法重定向我的 MySQL 数据库上的所有 id,而无需像下面这样手动编码所有这些,因为这将是不切实际和不可能的任务? If not what would be best practice in my situation after a massive website URL change?如果不是,在大型网站 URL 更改后,我的最佳做法是什么?

RewriteRule ^article\.php$ - [L]
RewriteCond %{QUERY_STRING} ^article_id=224509$
RewriteRule ^securitieslendingnews/article.php/?$ https://www.securitiesfinancetimes.com/securitieslendingnews/article.php?article_id=224509 [L,NE,R=301]

Thank you for any help in advance.感谢您提前提供任何帮助。

Not tested but something like this..未经测试,但类似这样的东西..

RewriteRule ^securitieslendingnews/article.php?article_id=([0-9]+)$ ./securitieslendingnews/article.php?article_id=$1 [L,NE,R=301]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM