How can I setup a 302 or 301 redirect from a subdomain to an external site?
-
Hello, I need to setup URL redirect 302 from something.mydomain.com to externaldomain.com/path
Since I am pointing my A records to cloudron, my DNS provider is unable to do this for me and they told me it has to be done on Cloudron's end.
Thank you for your email! I'm happy to clarify. Though the DNS of your account is hosted by Fastmail. We can only set up such a redirect website if the A records of the domain are pointing to our IPs. Currently, I can see that you've pointed the A records to a different service. Please contact your WebHost and they'll let you know what needs to be done to set up such a redirect. If they suggest creating any additional records, you can do so from the Settings->Domains->Edit(for your domain)-> Customize DNS screen. Feel free to contact me with any additional questions!
-
Hi @subtlecourage,
this could be (sort of) achieved with the surfer app and a simple html. You can read more about it at https://forum.cloudron.io/post/19387.
-
Wouldn't the redirection feature of Cloudron simply work?
https://docs.cloudron.io/apps/#redirections
Andy
-
-
@fbartels said in How can I setup a 302 or 301 redirect from a subdomain to an external site?:
@micmc said in How can I setup a 302 or 301 redirect from a subdomain to an external site?:
Wouldn't the redirection feature of Cloudron simply work?
This would only work if the url to be redirected to is also the same Cloudron app.
Yeah, you're right.
-
@fbartels said in How can I setup a 302 or 301 redirect from a subdomain to an external site?:
Hi @subtlecourage,
this could be achieved with the surfer app and a simple html. You can read more about it at https://forum.cloudron.io/post/19387.
@scooke said in How can I setup a 302 or 301 redirect from a subdomain to an external site?:
@fbartels I hope op will let us know if they tried this or not.
HUZZAH!! That worked!
I will have to see how advanced surfer will let me get with site design so it is not as ugly as while background and black text. But this is an AWESOME STARTING POINT!!
Thanks!
-
@subtlecourage just set the refresh to "0" and you shouldn't even see that.
Or change the color of the page.
-
@subtlecourage ..or prep a nice subliminal message ;-]
-
@subtlecourage said in How can I setup a 302 or 301 redirect from a subdomain to an external site?:
@robi
HAHAHAHAThats an excellent idea.
Thanks for clicking, dont forget to buy everything!!
"Teleportation occurring please hold on..."
-
It's very simple. Just spin up a LAMP app with something.mydomain.com as the location. Then, in the file manager create a file .htaccess in the public directory with the following content:
# Permanent URL redirect RewriteEngine on Redirect 301 / https://externaldomain.com/path
Any requests to something.mydomain.com will then be forwarded to externaldomain.com/path
There is plenty of documentaton on this if you do a Google search for 301 redirect .htaccess. there are also generators that will provide you with the correct code for different scenarios, for example redirecting specific pages.
-
Alrighty, so I'm running into this issue night now. I'm trying to setup over 9 different redirects to htmls. Basically, sub1.domain.com connects to domain.com/sub1.html for all of them. This being a setup for redirection generator links. Theoretically, I could create a app for every sub domain, or I could just setup sub-directories for it. But, I am importing a project that is live, so I'm going to have to stick with the sub-domain method. Is there a way to bypass the redirection without making tons of apps? I know I could do a rewrite condition, however that only works when the redirect is made on the site through htaccess. But redirecting it through the panel ensures that you never reach the htaccess under the sub domain and if you don't specify the sub-domain, the web-server never responds to it.
-
@toxicdorito I see now, that the LAMP App is missing alias, I'm unsure if that might be the fix, but I think so. All I know is, I can't figure this stuff out
-
@toxicdorito yes the alias features + htaccess rewrite using the LAMP app should solve this for you.
The LAMP app also has
multiDomain
and thus alias support. Can you double check in the Location tab of the app configure screen in your Coudron dashboard?