我正在尝试将一些链接从旧的 WordPress 网站重定向到新的网站。
我的.htaccess 文件:
Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteRule ^press-release-mcp-and-tmr-integrate-to-seize-maritime-communications-opportunities$ http://newurl.com/news/press-release-mcp-and-tmr-integrate-to-seize-maritime-communications-opportunities [L,R=301]
RewriteRule ^press-release-bygger-verdens-storste-4g-nett-offshore$ http://newurl.com/news/press-release-bygger-verdens-storste-4g-nett-offshore [L,R=301]
RewriteRule ^press-release-33-cruise-ships-with-mobile-and-internet-services-from-mcp$ http://newurl.com/news/press-release-33-cruise-ships-with-mobile-and-internet-services-from-mcp [L,R=301]
RewriteRule ^press-release-mcp-to-install-4g-infrastructure-on-norwegian-continental-shelf-with-shell$ http://newurl.com/news/press-release-mcp-to-install-4g-infrastructure-on-norwegian-continental-shelf-with-shell [L,R=301]
RewriteRule ^press-release-returns-to-win-offshore$ http://newurl.com/news/press-release-returns-to-win-offshore [L,R=301]
RewriteRule ^can-it-be-true-that-todays-improvements-in-communication-for-the-offshore-environment-initiate-a-paradigm-shift$ http://newurl.com/news/can-it-be-true-that-todays-improvements-in-communication-for-the-offshore-environment-initiate-a-paradigm-shift [L,R=301]
RewriteRule ^how-mobile-data-roaming-increases-your-mobile-data-traffic$ http://newurl.com/news/how-mobile-data-roaming-increases-your-mobile-data-traffic [L,R=301]
RewriteRule ^why-is-improved-personalized-communication-paramount-for-the-offshore-industry$ http://newurl.com/news/why-is-improved-personalized-communication-paramount-for-the-offshore-industry [L,R=301]
RewriteRule ^why-mobile-data-will-remain-the-most-important-source-of-revenue$ http://newurl.com/news/why-mobile-data-will-remain-the-most-important-source-of-revenue [L,R=301]
RewriteRule ^color-line-extends-contract-with-mcp$ http://newurl.com/news/color-line-extends-contract-with-mcp [L,R=301]
RewriteRule ^author/mcp$ http://newurl.com/business/about-us/news-events [L,R=301]
RewriteRule ^author/andreas-lutebergetmcp-com$ http://newurl.com/business/about-us/news-events [L,R=301]
RewriteRule ^author/roar-walderhaugmcp-com$ http://newurl.com/business/about-us/news-events [L,R=301]
RewriteRule ^archives/press-releases$ http://newurl.com/business/about-us/news-events [L,R=301]
RewriteRule ^archives/news$ http://newurl.com/business/about-us/news-events [L,R=301]
RewriteRule ^archives/insights$ http://newurl.com/business/about-us/news-events [L,R=301]
RewriteRule ^need-for-offshore-speed$ http://newurl.com/business/about-us/news-events [L,R=301]
RewriteRule ^customers$ http://newurl.com/service-support [L,R=301]
RewriteRule ^about-mcp/travel-smart$ http://newurl.com/service-support [L,R=301]
RewriteRule ^about-mcp/organization$ http://newurl.com/business/about-us/the-team [L,R=301]
RewriteRule ^about-mcp/career$ http://newurl.com/business/about-us/careers [L,R=301]
RewriteRule ^about-mcp$ http://newurl.com/business/about-us [L,R=301]
RewriteRule ^cruise$ http://newurl.com/business/cruise [L,R=301]
RewriteRule ^ferry$ http://newurl.com/business/ferry [L,R=301]
RewriteRule ^fisheries$ http://newurl.com/business/fisheries [L,R=301]
RewriteRule ^solutions$ http://newurl.com [L,R=301]
RewriteRule ^offshore$ http://newurl.com/business/offshore [L,R=301]
RewriteRule ^contact-us$ http://newurl.com/business/about-us/contact [L,R=301]
RewriteRule ^history$ http://newurl.com/business/about-us/history [L,R=301]
RewriteRule ^installations-in-operation$ http://newurl.com/business/about-us/installations-in-operation [L,R=301]
RewriteRule ^mcp-insight$ http://newurl.com/business/about-us/news-events [L,R=301]
RewriteRule ^newsevents$ http://newurl.com/business/about-us/news-events [L,R=301]
RewriteRule ^protu_roaming.php$ http://newurl.com/business/about-us/installations-in-operation [L,R=301]
RewriteRule ^coverage.php$ http://newurl.com/business/about-us/installations-in-operation [L,R=301]
RewriteRule ^press-kit$ http://newurl.com/business/about-us/news-events [L,R=301]
RewriteRule (.*) http://newurl.com [L,R=301]
一些旧链接按照规则指定的方式正确重定向到新链接(cruise、about-mcp、history),但其他链接仅与最后一条规则匹配(前 16 条规则;从“press-release-mcp-and-tmr...”到“archives/insights”)。
我试过的每个 htaccess 测试器都说规则没问题(http://htaccess.mwl.be/,http://martinmelin.se/rewrite-rule-tester/),但是当我尝试使用浏览器或 curl 时,却不行。
知道如何修复此问题吗?
更新
有效的方法:
RewriteRule ^need-for-offshore-speed$ http://newurl.com/business/about-us/news-events [L,R=301]
RewriteRule ^customers$ http://newurl.com/service-support [L,R=301]
RewriteRule ^about-mcp/travel-smart$ http://newurl.com/service-support [L,R=301]
RewriteRule ^about-mcp/organization$ http://newurl.com/business/about-us/the-team [L,R=301]
RewriteRule ^about-mcp/career$ http://newurl.com/business/about-us/careers [L,R=301]
RewriteRule ^about-mcp$ http://newurl.com/business/about-us [L,R=301]
RewriteRule ^cruise$ http://newurl.com/business/cruise [L,R=301]
RewriteRule ^ferry$ http://newurl.com/business/ferry [L,R=301]
RewriteRule ^fisheries$ http://newurl.com/business/fisheries [L,R=301]
RewriteRule ^solutions$ http://newurl.com [L,R=301]
RewriteRule ^offshore$ http://newurl.com/business/offshore [L,R=301]
RewriteRule ^contact-us$ http://newurl.com/business/about-us/contact [L,R=301]
RewriteRule ^history$ http://newurl.com/business/about-us/history [L,R=301]
RewriteRule ^installations-in-operation$ http://newurl.com/business/about-us/installations-in-operation [L,R=301]
RewriteRule ^mcp-insight$ http://newurl.com/business/about-us/news-events [L,R=301]
RewriteRule ^newsevents$ http://newurl.com/business/about-us/news-events [L,R=301]
RewriteRule ^protu_roaming.php$ http://newurl.com/business/about-us/installations-in-operation [L,R=301]
RewriteRule ^coverage.php$ http://newurl.com/business/about-us/installations-in-operation [L,R=301]
RewriteRule ^press-kit$ http://newurl.com/business/about-us/news-events [L,R=301]
RewriteRule (.*) http://newurl.com [L,R=301]
无效的方法:
RewriteRule ^press-release-mcp-and-tmr-integrate-to-seize-maritime-communications-opportunities$ http://newurl.com/news/press-release-mcp-and-tmr-integrate-to-seize-maritime-communications-opportunities [L,R=301]
RewriteRule ^press-release-bygger-verdens-storste-4g-nett-offshore$ http://newurl.com/news/press-release-bygger-verdens-storste-4g-nett-offshore [L,R=301]
RewriteRule ^press-release-33-cruise-ships-with-mobile-and-internet-services-from-mcp$ http://newurl.com/news/press-release-33-cruise-ships-with-mobile-and-internet-services-from-mcp [L,R=301]
RewriteRule ^press-release-mcp-to-install-4g-infrastructure-on-norwegian-continental-shelf-with-shell$ http://newurl.com/news/press-release-mcp-to-install-4g-infrastructure-on-norwegian-continental-shelf-with-shell [L,R=301]
RewriteRule ^press-release-returns-to-win-offshore$ http://newurl.com/news/press-release-returns-to-win-offshore [L,R=301]
RewriteRule ^can-it-be-true-that-todays-improvements-in-communication-for-the-offshore-environment-initiate-a-paradigm-shift$ http://newurl.com/news/can-it-be-true-that-todays-improvements-in-communication-for-the-offshore-environment-initiate-a-paradigm-shift [L,R=301]
RewriteRule ^how-mobile-data-roaming-increases-your-mobile-data-traffic$ http://newurl.com/news/how-mobile-data-roaming-increases-your-mobile-data-traffic [L,R=301]
RewriteRule ^why-is-improved-personalized-communication-paramount-for-the-offshore-industry$ http://newurl.com/news/why-is-improved-personalized-communication-paramount-for-the-offshore-industry [L,R=301]
RewriteRule ^why-mobile-data-will-remain-the-most-important-source-of-revenue$ http://newurl.com/news/why-mobile-data-will-remain-the-most-important-source-of-revenue [L,R=301]
RewriteRule ^color-line-extends-contract-with-mcp$ http://newurl.com/news/color-line-extends-contract-with-mcp [L,R=301]
RewriteRule ^author/mcp$ http://newurl.com/business/about-us/news-events [L,R=301]
RewriteRule ^author/andreas-lutebergetmcp-com$ http://newurl.com/business/about-us/news-events [L,R=301]
RewriteRule ^author/roar-walderhaugmcp-com$ http://newurl.com/business/about-us/news-events [L,R=301]
RewriteRule ^archives/press-releases$ http://newurl.com/business/about-us/news-events [L,R=301]
RewriteRule ^archives/news$ http://newurl.com/business/about-us/news-events [L,R=301]
RewriteRule ^archives/insights$ http://newurl.com/business/about-us/news-events [L,R=301]
答案1
问题的一部分可能是这,永久重定向会被浏览器缓存(而对于 Google Chrome,私人模式则没有帮助)。
我发现的另一件事(我既知道原始 URL 也知道新 URL)是,在 Firefox 上(在私人模式下),旧 URL 不再重定向(错误),它只会抛出 404(因为错误的重定向已从 .htaccess 文件中删除)。这让我更加认为问题出在缓存上。
这些是我迄今为止的发现,我认为不应该从另一个角度来看待这个问题,因为新系统的行为与测试环境不同。
如果有的话,我真的很高兴看到比这个更好的答案:)