How do I redirect a specific URL/ROUTE/PATH/LOCATION to another?

mk flag

Say my client (current device) wants to connect to a URL, say, how do I serve or redirect to another specified URL, say, and prevent the client from reaching

What software can I use?

Saxtheowl avatar
by flag
What operating system are you using ? please provide more information
Anm avatar
mk flag
I am using linux @Saxtheowl
in flag

If I understand your setup, you have some external domain,, controlled by a 3rd party, with a website running on it, controlled by someone else. You want to allow access to that site generally, but block certain URLs.

There are a few solutions to this; they all boil down to some sort of proxy server. You would proxy web traffic via this proxy server and have a block/redirect list configured in it, which would deal with predefined exceptions.

One free solution is squid caching proxy, which does have redirectors support (here are details in the documentation - Do note though that it's very much not trivial to set this up correctly and maintain it. No disrespect, but based on the fact that you had to ask this question, I suspect you may struggle to do this successfully.

by flag

You should use a reverse proxy like Nginx first install it sudo apt-get install nginx then go to the configuration file at /etc/nginx/sites-available/ and put this inside:

server {
    listen 80;

    location /spam/eggs/123 {
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

then enable it with ln -s /etc/nginx/sites-available/ /etc/nginx/sites-enabled/

With this configuration, when a client tries to connect to, Nginx will redirect the request to

then reload Nginx sudo systemctl reload nginx

Nikita Kipriyanov avatar
za flag
it is always better not to modify existing distribution-installed files it possible, but to add your own alongside into the configuration drop directory (so a package update won't disturb it, for example). In this case, better put this content into `/etc/nginx/sites-avaliable/` and enable it with `ln -s /etc/nginx/sites-available/ /etc/nginx/sites-enabled/`. Also restart is not required, reload is enough.
Anm avatar
mk flag
This did not work for me, isnt nginx a reverse proxy? is not owned by me but I would like to redirect a specific location on it, and allow the rest
sa flag
I downvoted this because it doesn't answer the question and doesn't work.
I sit in a Tesla and translated this thread with Ai:


Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.