G
G
GreenX52021-09-21 22:03:05
Apache HTTP Server
GreenX5, 2021-09-21 22:03:05

Dynamic variable in .htaccess?

The host has a static redirect from the subdomain to the backserver at 1.1.1.1

<IfModule mod_rewrite.c>
RewriteCond %{HTTP_HOST} ^subdomen.domen.com$ [NC]
RewriteRule (.*) 1.1.1.1 [L,R=301,QSA]
</IfModule>

But that's just a backserver on a dynamic IP (1.1.1.1 will be changed by the backserver provider), and even DDNS will not work.
The first option that came to mind is that when changing its external IP, the backserver writes it to a file on the host, and .htaccess reads it from the file into a variable (1.1.1.1 now)
Is this feasible?
Or let it rewrite the entire .htaccess?
Other options?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Viktor Taran, 2021-09-22
@shambler81

Your solution is strange in itself, back or it must have a static IP or DNS, even if technical.
The third option is clearly crutches.
Yes, in bash it will be one line, but this is a crutch, moreover, some kind of horse.
Can you solve the problem with back servers.
If this is something serious, there is a dns binding,
if not, then why would they change the IP?
if this is homemade, pay 100 rubles a month for an IP.
believe the crutch is not worth it.
Describe in more detail the reason why backs change, whether you have access to them, whether there is an API and how you collect to track their dynamic IPs, even in theory.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question