TAGS :Viewed: 15 - Published at: a few seconds ago
[ PHP header 301 redirect not working due to browser cache ]
My code is the following:
<?php
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://newsite.com/");
?>
The issue I am having is several users have already reported the page not redirecting them and instead showing them the content on the old page, but later in the day it showed the correct redirect.
I know it has to be related to the caching but which is the most efficient and standardized way to bypass the cache for the above redirect? Would I use php or javascript?
Thank you.
Answer 1
Try this:
header('Cache-Control: no-cache');
header('Pragma: no-cache');
The browser may ignore your request, but this should do the trick.