简体   繁体   中英

Redirect old website with parameters to new website with parameters under the same domain

I'm trying to redirect my old pages as the website is going through an upgrade (from coldfusion to PHP) and we want visitors in the past to still be able to access an article using the old link.

http://examplepage.com/article.cfm?ArticleID=3163

to

http://examplepage.com/articles.php?id=3163

I have been through many articles but can't find one that works the way i want it to, please advice!

Update: I found a solution, it works but is this the best way?

RewriteEngine On

RewriteCond %{THE_REQUEST} /article\.cfm\?ArticleID=(\d+) [NC]
RewriteRule ^ /article\.php\?id=%1 [R=301,L,NE]
RewriteEngine On
RewriteCond %{QUERY_STRING} ArticleID=([^&]+) 
RewriteRule ^article.cfm$ /articles.php?id=%1 [R=301,L]

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