Answer the question
In order to leave comments, you need to log in
How to implement dynamic redirect control?
There are two servers for serving distributions:
download.example.com (nginx->apache)
static.example.com (CDN) You
need to make a "switch" mechanism that will control which of these servers the distribution will be served for downloading. Literally at the level of some php script - a list of distributions and a switch download.example.com/CDN.
The solution in the forehead is to generate a .htaccess file. But I would like to exclude apache from this process.
Which way to look?
Answer the question
In order to leave comments, you need to log in
As a result, he acted as follows - when the manager enters the web interface and turns on the CDN for one of the distributions, an empty file is written to a certain directory (for example, /cdnenabled) by the mask product-name.trig. Nginx checks the existence of this file, and if it exists, the user is redirected to the CDN when requesting the distribution. Otherwise, nginx gives it to you.
Example nginx config:
...
server {
listen 80;
location ~^/en/(.*)/(.*)-setup.exe$ {
set $product $1;
set $setup_part $2;
if (-f /home/www/example.com/public_html/cdnenabled/$product.trig) {
rewrite ^ http://cdnserver.com/en/$product/$product-setup.exe; #редирект на CDN в случае существования файла
}
#Отдать дистрибутив или показать 404.
try_files /home/www/example.com/public_html/en/$product/$product-setup.exe /home/www/example.com/public_html/404.html;
}
}
...
What prevents you from going down a completely stupid path, and when you generate a page with a link, immediately substitute the one you need.
Or generate a redirect on the server on the page,
more options are listed
en.wikipedia.org/wiki/URL_redirection
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question