我可以强制 .htaccess 刷新吗?
我们正在将网站从一个 CMS 迁移到另一个 CMS。 .htaccess 文件已更改,需要刷新才能使新站点正常工作。据我了解,只有清除浏览器缓存后,.htaccess 文件才会刷新?对于那些创建网站的人来说,清除我们的缓存是没有问题的,但是有没有一种方法可以让用户的浏览器获取新的.htaccess 文件,而无需用户主动手动清除缓存呢?
We are moving a site from one CMS to another. The .htaccess file has been changed and it needs to be refreshed for the new site to work right. From what I understand the .htaccess file will only be refreshed if the browser cache is cleared? It is fine for those creating the site to clear our cache, but is there a way to get the users' browsers to get the new .htaccess file without the user clearing cache manually on his own initiative?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
来自 https://stackoverflow.com/a/7749784/1066234
from https://stackoverflow.com/a/7749784/1066234
替换 .htaccess 文件后,某些服务器将立即重新加载。
如果是这样,它会立即用于所有后续请求。您不需要刷新任何缓存。
有些服务器只定期检查 htaccess。
Some servers will reload as soon as you replace the .htaccess file.
If so it instantly be used for all subsequent requests. You do not need to refresh any caches.
Some servers only check htaccess periodically.
如果您已经有 R=301 重定向,那么您只是更改了它在 htaccess 中重定向到的位置,但它没有为您更新,那么它可能已缓存在您的浏览器中。您无法在该页面上进行硬刷新,因为它会重定向。您可以在其他浏览器中尝试,如果可以正常运行,则只需清除 Chrome 中的缓存即可。设置>隐私>清除浏览数据。然后你只需要检查“缓存的图像和文件”这不会清除你的登录或任何东西。
If you already had a R=301 redirect, then you just changed where it redirects to in htaccess, but it isn't updating for you, then it's probably cached in your browser. You can't do a hard refresh on that page because it redirects. You can try in another browser and if it works there, you just need to clear cache in Chrome. Settings > Privacy > Clear browsing data. Then you only need to check "Cached images and files" This will not clear your logins or anything.
我的 .htaccess 文件中有一个重写规则,
一旦我在本地主机中打开该站点,它就永远不会给我硬刷新页面的机会。
解决方案:我添加了一个随机字符串,如 localhost/mywebsite/index.php?1234
I had a rewriterule in my .htaccess file like,
and once I opened the site in localhost it never gave me a chance to hard refresh the page.
Solution: I added a random string like localhost/mywebsite/index.php?1234