Disable Direct IP Access to Apache Website

I want to share how I solved an issue with Cache Enabler caching duplicate copies of my WordPress website content. I should note that my website is hosted on a shared host that is running Apache. If you are using Cache Enabler, you will see your pages and posts cached under, for example:

All the cached pages and posts are under the website domain-name directory. My problem was, I was also seeing two additional directories that looked like:

The IP address was the address being used by my website domain. Under these “IP” directories, I was seeing duplicate copies of my posts and pages being cached. And, when I tried to clear my cache, the files under the IP directories were not being cleared.

My solution was to add a bit of code to my .htaccess file. I had to use the .htaccess method because my site is on a shared Apache host. This is the code that I added:

A few notes. Of course, use your actual website domain IP address. I placed this chunk of code at the beginning of my .htaccess file in my WordPress site root directory. If you had the same issue as I did with Cache Enabler creating the “IP” directories, you will have to manually remove them. They should not reappear.

The RewriteRule generates a “403 Forbidden” response for any direct IP access attempted.

Hope this was helpful!

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.