Server caching .htaccess file? Here’s how to solve it
![](https://lucrebem.com.br/wp-content/uploads/2021/05/htacess2-1024x410.jpg)
I had a problem with the site’s htaccess file yesterday, what happened was that the 301 redirects were not working. Inside my htaccess file I have many 301 redirects that worked just fine for a long time, but yesterday I tried to add new entries and they didn’t work. When I checked it closely, I noticed that the server doesn’t seem to be using the version that I’m saving. It looks like the server is using another file, because I’ve already cleared my browser cache, I tried another browser, I’ve cleared my website cache and I’ve even restarted the server, still the same problem. I’m using a VPS with CentOS and DirectAdmin.
This tutorial is for whoever is using this method to redirect the URLS:Redirect 301 /category1/post /category2/post
I did that, but the server wasn’t loading the modified file. I didn’t have any caching plugin enabled, I also disabled all my site’s plugins, but still the very same problem.
Yes, mod_rewrite
is working, like I said, the redirects that I created before are working, it’s just that now it seemed like the server was caching an old file. I tried to search about it and I couldn’t find a solution anywhere, I even contacted my host and they didn’t solve it.
So today I had another talk with my host and they solved it, how?
Like this:
Currently OpenLiteSpeed reads .htaccess on starting time, so if some new .htaccess files are created, or current ones modified – changes are not in effect until the reload of OpenLiteSpeed service. Please note that DirectAdmin provides customers an ability to reload OpenLiteSpeed directly from the user level, and does this automatically for the .htaccess files edited in File Manager. It’s also reloaded automatically when uploaded using FTP if pureftpd_uploadscan option is used in CustomBuild. However, if you would like to have a cronjob setup, which would reload OpenLiteSpeed every X minutes if there are newer .htaccess files that the starting time of OpenLiteSpeed, you may use a cronjob like (*/3 means every 3 minutes, you may change it to happen less/more often):
*/3 * * * * root if ! find /home/*/domains/*/*_html/ -maxdepth 2 -type f -newer /usr/local/lsws/cgid -name '.htaccess' -exec false {} +; then /usr/local/lsws/bin/lswsctrl restart; fi
Cronjob can be created as /etc/cron.d/openlitespeed_htaccess_scan. It scans for .htaccess files in public/private_html folders, with a max depth of 2 folders (it can be changed to 3, or unlimited at all, however, it could slow the scanning down).
So that’s pretty much it, just a caching problem with Litespeed.
Source: https://help.directadmin.com/item.php?id=2097
Por Matheus Lopes