简体   繁体   中英

Dynamic 301 redirects

I'm trying to redirect thousands of ids on a single dynamic PHP and MySQL page. 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!

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. I have tirelessly looked for an answer, but to no avail.

For example the below redirect is for just one 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? If not what would be best practice in my situation after a massive website URL change?

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]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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