if($url = 'www.xxx.com'){ header('HTTP/1.1 301 Moved Permanently'); header('Location: $target_url); } 以上代码,301重定向在浏览器访问过,浏览器会记住,认为是永久跳转了。会直接跳过代码执行。但有修改$target_url,在不清楚浏览器缓存的情况下,无法生效。请问有什么解决办法吗
要访问url后面加个时间戳,比如 http://localhost/index.php?t=... index.php 里面是你跳转的代码 if($url = 'www.xxx.com'){ header('HTTP/1.1 301 Moved Permanently'); header('Location: $target_url); }
其实就是浏览器的浏览缓存,两种解决办法:
一就是在连接上添加每次都会变化的随机数
二就是禁用缓存,参考 http协议的Cache-Control
要访问url后面加个时间戳,比如 http://localhost/index.php?t=...
index.php 里面是你跳转的代码