简体   繁体   English

将具有参数的旧网站重定向到具有相同域下的参数的新网站

[英]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. 我正尝试重定向我的旧页面,因为网站正在进行升级(从Coldfusion到PHP),并且我们希望过去的访问者仍然能够使用旧链接访问文章。

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

to

http://examplepage.com/articles.php?id=3163 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]

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

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