I've run into odd situation and feel like I'm close to a solution but can't quite get it to work.
I have a client who's site I'm building on one of our cpanel servers and they have a number of temperature monitors that need to send data to the site every couple of minutes. However their temp monitors are quite old and don't support DNS so they can't use their domain name and have to make an IP based request. (they also can't do SSL and of course while the client does plan on replacing them at some point that's not going to happen anytime soon.)
(in all examples I'm using domain.com in place of the reail domain and 127.0.01 in place of the real IP)
So - basically we have an endpoint like: http://domain.com/util/gettemp.php which is called with a query string containing the data. But the devices that need to reach that endpoint can only do so with the IP and not the domain like: http://127.0.0.1/util/gettemp.php with the query string.
I initially thought mod_userdir would take care of this. But...their devices also don't allow ~'s in urls', so simply loading it as http://127.0.0.1/~client/util/gettemp.php won't work.
I tried adding a redirect with the includes editor like:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule "^util/gettemp.php" "http://www.domain.com/util/gettemp.php" [QSA,L]
</IfModule>
But whether I put it in pre-Main, or pre-virtualHost, or post-virtualHost it doesn't work.
I also tried adding a virtual host config around it and putting it in pre-Main:
<VirtualHost 127.0.01:80>
ServerAlias 127.0.01
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule "^util/gettemp.php" "http://www.domain.com/util/gettemp.php" [QSA,L]
</IfModule>
</VirtualHost>
Which...broke the default cpanel 404 page...but didn't give the rewrite I was hoping for either.
Note - I can't just do a 301/302 redirect...the devices in question just ignore them, I need to actually remap the URL for apache.
Am I just making an error in my rewrite rule and how I'm adding it - or is there another solution for this anyone can offer?
I have a client who's site I'm building on one of our cpanel servers and they have a number of temperature monitors that need to send data to the site every couple of minutes. However their temp monitors are quite old and don't support DNS so they can't use their domain name and have to make an IP based request. (they also can't do SSL and of course while the client does plan on replacing them at some point that's not going to happen anytime soon.)
(in all examples I'm using domain.com in place of the reail domain and 127.0.01 in place of the real IP)
So - basically we have an endpoint like: http://domain.com/util/gettemp.php which is called with a query string containing the data. But the devices that need to reach that endpoint can only do so with the IP and not the domain like: http://127.0.0.1/util/gettemp.php with the query string.
I initially thought mod_userdir would take care of this. But...their devices also don't allow ~'s in urls', so simply loading it as http://127.0.0.1/~client/util/gettemp.php won't work.
I tried adding a redirect with the includes editor like:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule "^util/gettemp.php" "http://www.domain.com/util/gettemp.php" [QSA,L]
</IfModule>
But whether I put it in pre-Main, or pre-virtualHost, or post-virtualHost it doesn't work.
I also tried adding a virtual host config around it and putting it in pre-Main:
<VirtualHost 127.0.01:80>
ServerAlias 127.0.01
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule "^util/gettemp.php" "http://www.domain.com/util/gettemp.php" [QSA,L]
</IfModule>
</VirtualHost>
Which...broke the default cpanel 404 page...but didn't give the rewrite I was hoping for either.
Note - I can't just do a 301/302 redirect...the devices in question just ignore them, I need to actually remap the URL for apache.
Am I just making an error in my rewrite rule and how I'm adding it - or is there another solution for this anyone can offer?