大网数据广告活动
网站运营与故障问答

301 Redirect not working as expected

· 52CE 我爱测

I am in the process of doing a website redesign. We have changed the domain name and hosting server for the new project. Following are the rules that I am using in my htaccess file to perform a 301 redirect from the old domain to…

问题原文

原帖链接 · Sid · CC BY-SA 4.0

I am in the process of doing a website redesign. We have changed the domain name and hosting server for the new project. Following are the rules that I am using in my htaccess file to perform a 301 redirect from the old domain to the new one:

Redirect 301 / http://www.newdomain.com/

Redirect 301 /about-us http://www.newdomain.com/about-us

Redirect 301 /locate-us http://www.newdomain.com/contact-us

RedirectMatch 301 .* http://www.newdomain.com/

The first two redirects are working as expected however the 3rd one is being redirected to http://www.newdomain.com/locate-us instead of http://www.newdomain.com/contact-us.

已采纳解答

原帖链接 · MrWhite · CC BY-SA 4.0

It seems it was a caching issue in this instance.

Bear in mind that any 301 (permanent) redirects that may have been in place earlier or had simply been used in testing (perhaps in error), are cached persistently by browsers (and possibly intermediary caches).

For this reason it can be beneficial to test with 302 (temporary) redirects until it's confirmed they work OK. And/or test with the browser's developer tools (object inspector) open and caching disabled. eg. In Google Chrome's inspector, check the "Disable cache" checkbox on the "Network" tab.

The "Network" tab in the browser's developer tools helps to validate exactly what redirects are occurring, 3xx status codes and when. This will also tell you whether the redirect was from cache (if caching is enabled) or whether it originated from the server.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Webmasters Stack Exchange
适用范围
以原帖系统、软件版本与发布日期为准(2019-04-03)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。