-
I originally setup YOURLS as a subfolder in my main web directory (public_html/links) on my webhost (hostgator). So the yourls installation path and links are: However, I didn't really think that through very carefully and I realize now I would have been better to establish YOURLS as a subdomain instead (e.g. links.example.com) as I need to split my website off to a new host managed by my web designer where I can't have access to and manage something like YOURLS. So the www website will be on one host and I will keep my hosting account and run YOURLS on a subdomain. I have that now setup and I have created duplicate short urls on the new installation. The problem that I have is that I have already created some yourls short links (e.g.) www.example.com/links/hello and those are now in distribution (actually printed as QR codes on physical products). So I need to keep those old links alive somehow. I'd like to know if it's possible to setup a redirect in my old www.example.com/links that redirects everything to the same path at links.example.com? I feel like this should be achievable by .htaccess rewrites, but everything I tried has failed. I'm not an .htaccess guru so I could be doing it wrong. Or potentially there is some nuanced issue with YOURLS that would prevent an .htaccess solution from working? To further illustrate this scenario I have the following short YOURLS link on my original installation: www.example.com/links/product1 And this link has been repeated at my new subdomain YOURLS install: links.example.com/product1 So what I need is an .htaccess rule that wildcard rewrites www.example.com/links/* to links.example.com/* |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
This should be very simple. A web search for "htaccess redirect subdirectory to another domain" gave me, as the first result, https://webmasters.stackexchange.com/q/25522/844 with a couple different approaches depending on where you want to keep the They've kept the subdirectory on the new domain, but you can remove it and simply redirect to |
Beta Was this translation helpful? Give feedback.
-
Thanks @dgw I can confirm that works perfectly. All that is required is to make sure the short urls are mirrored/replicated at the new destination and old ones will work. I tried to get way too clever for my own good in my .htaccess redirect when this simple code snippet in the old /links/ directory worked perfectly:
|
Beta Was this translation helpful? Give feedback.
This should be very simple. A web search for "htaccess redirect subdirectory to another domain" gave me, as the first result, https://webmasters.stackexchange.com/q/25522/844 with a couple different approaches depending on where you want to keep the
.htaccess
file related to these redirects.They've kept the subdirectory on the new domain, but you can remove it and simply redirect to
https://links.example.com/$1
.