Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Scruffie

Redirect URL with Nginx

For posterity in case anyone comes across this.

 

Within the default nginx conf file I added a 301 rule

 

location /somepath {

     return 301 https://linustechtips.com/ ;

}

 

now, when I browse to subdomain.domain.com/somepath it will take me to https://linustechtips.com/

Recommended Posts

Posted · Original PosterOP

Hey guys, so as it says I'm wondering if this is possible..

 

I have a droplet with DigitalOcean, and an a record pointing to said droplet. Would this be possible

 

subdomain.domain.com/link1 -> route over to droplet with nginx, nginx has a 301 conf that says subdomain.domain.com/link1 will return randomsite.com/somepath

 

I'm not hosting the website on the droplet, just using it to redirect the URL. I can't do it at a DNS level as I don't have access to the domain, so I'm left with routing it through the droplet.

 

Let me know if I can provide further information!

Link to post
Share on other sites

i don't really get what you're trying to do here as why don't you just do a redirect straight from the link instead of using a dns and domain that you have no access to. fell free to correct me if i ain't getting what you're putting down 

Link to post
Share on other sites
Posted · Original PosterOP
17 minutes ago, MollyXD said:

i don't really get what you're trying to do here as why don't you just do a redirect straight from the link instead of using a dns and domain that you have no access to. fell free to correct me if i ain't getting what you're putting down 

long story short, it's for someone else who is paying me. what they want goes, no questions. 

Second, I'll explain it more thoroughly as I did a poor job before.

 

For example, lets say I have this link: https://static.boredpanda.com/blog/wp-content/uploads/2018/10/cutest-puppy-dog-pictures-coverimage.jpg

Well, I don't want to type that link, but I want to redirect it from my own url. Now, I don't have access to the DNS control panel to create a domain forward rule. What I do have however is a subdomain pointing to a linux vm that I'm using. My plan was to use that VM, and Nginx (or apache, whatev) to create a link forward rule. so I was going to forward, or use a 301 return rule to return the above link when someone writes subdomain.domain.com/somepath

Link to post
Share on other sites

You want to look at creating a Nginx reverse proxy.


#killedmywife #howtomakebombs #vgamasterrace

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


×