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.

  • 1
    Presumably newdomain.com points to a different server? Do you have any other directives in your .htaccess file? Have you checked the network traffic, and you are seeing a single 301 redirect? Or multiple redirects with different 3xx status? Make sure you've cleared your browser cache. (Test with 302s to avoid caching issues.) – MrWhite Apr 3 at 17:59
  • 1
    +MrWhite. It was a caching issue. Its working fine now. Thanks – Sid Apr 4 at 4:37
3

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.

  • Great tip about using 302s for testing. – Trebor Apr 4 at 15:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.