Allow IP address from text file in htaccess

#1
Hi all

.htaccess related.

I have just migrated from many years hosted on Apache servers to Litespeed.
I have NO access to any Litespeed server settings.
I believe that RewriteMap is not supported on Litespeed so I am now at a loss.

I used to use this example code in my .htaccess on Apache, but now the host does not allow %{REMOTE_HOST}

RewriteCond %{REMOTE_HOST} ^example\.com$ [NC]
RewriteCond %{REQUEST_URI} ^/wp-login\.php$
RewriteRule ^(.*)$ /blackhole.html [L]

I am accessing my site from a dynamic IP address so have written a script to obtain my current IP address to a filename: /home/xxx/public_html/currentip

I now need a way of reading that ip address contained within currentip, and using it for the request_uri and rewriterule above to work.

Thanks in advance.
 

serpent_driver

Well-Known Member
#2
Use %{HTTP_HOST} instead of %{REMOTE_HOST} like

Code:
RewriteCond %{HTTP_HOST} ^www\.[^.]+\.example\.com$
RewriteCond %{REQUEST_URI} ^/wp-login\.php$
RewriteRule ^(.*)$ /blackhole.html [L]
 
#3
Use %{HTTP_HOST} instead of %{REMOTE_HOST} like

Code:
RewriteCond %{HTTP_HOST} ^www\.[^.]+\.example\.com$
RewriteCond %{REQUEST_URI} ^/wp-login\.php$
RewriteRule ^(.*)$ /blackhole.html [L]
Unfortunately, the hosting company does not allow Rdns so Remote_host, Http_host will not work. (Tried that one first)
 
#5
Change hosting company......

Which version of LiteSpeed webserver do you use? LiteSpeed Enterprise or OpenLiteSpeed?
LiteSpeed V7.7 on WPX hosting, actually the fastest Wordpress hosting service today. So preventing users from making time consuming system calls. Hence I need the coding to obtain an entry as in the original post. Thanks anyway.
 
#9
There is no version 2.4xxxxxxx
Regardless of litespeed version numbers, my hosting company would NOT be using openlitespeed on its worldwide servers for it's millions of users. I in this case as a user only have access to PHP and MySQL version numbers.

Could someone help me with my original post please.

Thanks
 

serpent_driver

Well-Known Member
#10
If you have no access to LS settings, you can't have LiteSpeed Enterprise. OpenLiteSpeed is for free and the most used LiteSpeed version for hosting companies and for low budget hostings like WPX.

Your need to include text file in .htaccess doesn't work, neither in LSWS, OLS nor any other webserver.

The way how you want to protect wp-login.php is too complicated and can be solved much more easier.

Setup a single PHP file that sets a cookie at your choice if you request this page. Define rewrite rule in .htaccess

Code:
RewriteCond %{REQUEST_URI} ^\/wp-login\.php
RewriteCond %{HTTP_COOKIE} !your_cookie [NC]
RewriteRule .* - [F,L]
 
Last edited:
Top