Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I force .htaccess to refresh?

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?

like image 819
Johann Dyck Avatar asked Feb 03 '12 09:02

Johann Dyck


People also ask

How do I refresh a .htaccess file?

Simply go to your site and load the page that should be affected. Hit Ctrl + F5 to refresh everything (some computers require the F Lock to be on before you can use F5).

How long does it take for htaccess to update?

htaccess files follow the same syntax as the main configuration files. Since . htaccess files are read on every request, changes made in these files take immediate effect.

Does .htaccess get cached?

To answser the topic (not the question): No, . htaccess files are not cached by Apache.


3 Answers

If you're using RewriteRule, just use R instead of R=301. For other purposes, you'll have to clear your browser cache whenever you change a redirect.

from https://stackoverflow.com/a/7749784/1066234

like image 138
Avatar Avatar answered Oct 18 '22 15:10

Avatar


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.

like image 30
baynezy Avatar answered Oct 18 '22 15:10

baynezy


I had a rewriterule in my .htaccess file like,

 RewriteCond %{HTTPS} !on
 RewriteRule (.*) https://example.com%{REQUEST_URI} [L,R=301] 

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

like image 30
Mathew Avatar answered Oct 18 '22 15:10

Mathew