Heroku and subdomains - heroku

I have the domain ingledow.co.uk. I have recently been working on a Heroku app that is deployed to david.ingledow.uk and this has been done successfully.
However, I now want to redirect all my old domain and subdomains to david.ingledow.co.uk. Here is a list of domains I have that I want to redirect to my new subdomain:
ingledow.co.uk > david.ingledow.co.uk
www.ingledow.co.uk > david.ingledow.co.uk
blog.ingledow.co.uk > david.ingledow.co.uk
I've set CNAMEs to david.ingledow.co.uk. but I get the following error:
Heroku | No such app
There is no app configured at that hostname.
Perhaps the app owner has renamed it, or you mistyped the URL.
Any suggestions would be much appreciated!

If you're setting them as CNAME's then they are not redirects - it would be making your site available on www.ingledow.co.uk, blog.ingledow.co.uk. You'd have to add these all as custom domains to your application and then handle the redirect in your app. Instead you could set them up as redirects so when you go to blog.ingledow.co.uk you get redirected to david.ingledow.co.uk at DNS level.
See https://devcenter.heroku.com/articles/route-53#naked-root-domain for more info.

Related

Why does localtunnel not work when there is a redirect defined for a route in Laravel?

These devices are all on the same LAN:
Ubuntu server
Win 10 PC
iPhone
Android
On the Ubuntu server, the /etc/hosts file has:
127.0.0.1 rcw.lt
Also on the Ubuntu server, there is a Laravel app hosted by nginx: server_name rcw.lt;.
The / homepage route of my rcw.lt app uses a redirect (see https://laravel.com/docs/8.x/redirects and https://laravel.com/docs/8.x/helpers#method-redirect).
I run lt --port 80 --local-host rcw.lt &.
What does NOT work:
When browsing from Win 10 or iPhone or Android to the URL generated for the rcw.lt app (such as https://fat-tiger-93.loca.lt), it always tries to redirect to https://rcw.lt (and says ERR_CONNECTION_REFUSED).
What works:
I can browse to the provided generated URL and append a specific path onto it (such as https://fat-tiger-93.loca.lt/some-specific-route), and it works. Or I can remove the redirect from the / route (which I don't want to do).
Any ideas?
Is this a problem with how Laravel redirects work? Or a problem with localtunnel? Is there a workaround?
I really appreciate your help. :-)

Can I redirect appname.herokuapp.com to www.app.com?

I Heroku, is there any way to get my heroapp domain to point to my custom domain? I have APPNAME.herokuapp.com which was setup by heroku and I got www.appname.com. www.appname.com works. But I want APPNAME.herokuapp.com to redirect to www.appname.com.
In short:
appname.herokuapp.com redirect -> www.appname.com
Sure. You can detect the Host header in your code and redirect based on that.
In ruby for example:
if ENV["HTTP_HOST"] == "myapp.herokuapp.com"
// Send the redirection and finish the request
end

Setting up HTTPS DNS with Namecheap and Heroku

I know there have been very similar questions asked but both companies changed over time and it's been hard to get a full working solution.
I'd like to have a naked subdomain (mysite.io) but if I have to have www.mysite.io, that's fine too.
So on the heroku dashboard I have :
DOMAIN NAME : mysite.io DNS TARGET : mysite.io.herokudns.com
DOMAIN NAME : www.mysite.io DNS TARGET www.mysite.io.herokudns.com
I know I should probably only have one of those active but I'm not sure which...
Then, on the NameCheap dashboard, I have :
EDIT: I have read what seemed like a good answer, here's what I changed, awaiting to see if it's gonna work.
CNAME Record - www - www.mysite.io.herokudns.com
CNAME Record - # - mysite.io.herokudns.com
And no redirect
I will update if it works
UPDATE :
Using two CNAME records indeed worked fine, except that users can still connect in HTTP and not be redirected to HTTPS. I probably need to add a redirect for that.
If anyone is still having problems and your website opens without HTTPS. There is a line of code in rails applications which you should uncomment. Go to config/environments/production.rb In this file you will find a commented line "config.force_ssl = true". Uncomment this line and your application will always open up with https
Combination of two answers above will solve the problem for Rails applications:
Go to Namecheap and add the two following CNAME's:
Type: CNAME
Host: #
Value: www.yourdomain.com.herokudns.com
TTL: Automatic
Type: CNAME
Host: www
Value: www.yourdomain.com.herokudns.com
TTL: Automatic
And then follow second answer: "Go to config/environments/production.rb In this file you will find a commented line "config.force_ssl = true"."
That should do the trick.

Trying to remove www from custom URL for a Heroku app

I purchased a domain from namecheap.com and have pointed it to my Heroku app successfully:
www.markrandhawa.com
I'm now trying to prevent the www part from showing in the URL but having difficulty doing so. I've looked at the Heroku doc for adding custom domains and added the following code, but this hasn't worked:
heroku domains:add markrandhawa.com
In my namecheap account, I tried changing the '#' in 'All Host Records' to URL Frame but this didn't work either. When going into page source of markrandhawa.com, it said:
<frameset rows='100%, *' frameborder=no framespacing=0 border=0>
<frame src="http://www.markrandhawa.com/" name=mainwindow frameborder=no framespacing=0 marginheight=0 marginwidth=0></frame>
</frameset>
<noframes><h2>Your browser does not support frames. We recommend upgrading your browser.</h2><br><br>
<center>Click <a href="http://www.markrandhawa.com/" >here</a> to enter the site.</center>
</noframes>
I'm using Chrome.
However, when using a proxy, it seems as though my site is loading using mark.randhawa.com (without the www) as shown in the following link:
http://anonymouse.org/cgi-bin/anon-www.cgi/http://markrandhawa.com
I'm not sure what to try next.
Heroku has very limited support for hosting root domains. Your DNS provider must be able to set ALIAS records, which is something most services do not provide. If Namecheap does not provide this service, hosting your root domain on Heroku is not possible.
See https://devcenter.heroku.com/articles/custom-domains#root-domain for more information on configuring ALIAS records, or alternatively setting up a redirect proxy.

How can we get multi_site extension for Radiant working on Heroku?

Has anyone got RadiantCMS with multi_site working on Heroku? I actually tried it and it bombed big-time giving the error:
Heroku | No such app
There is no app configured at that hostname.
Perhaps the app owner has renamed it, or you mistyped the URL.
This is what I tried:
Go to tractor.heroku.com and login using admin / radiant.
If you see the 'Sites' section, you will find Foo and Bar sites.
I edited my /etc/hosts files and added foo.myapp.com and bar.myapp.com to the IP address that resolves to tractor.heroku.com (Not entirely sure if this is right)
Now type the URL "http://foo.myapp.com" in the browser and it gives me the above error.
Is there some special configuration required to get this working on Heroku?
So, I finally did get an answer from heroku support themselves. Pasting it here for everyone's benefit:
reception said:
fyi if you want a 301 redirect from appname.heroku.com url to yourdomain.tld i succeeded with this steps:
freeze radiant (in order to be able to modify application_controller.rb; see http://wiki.github.com/radiant/radiant/running-on-edge )
add this code to application_controller.rb inside class ApplicationController:
---->8
before_filter :redirect_domain
def redirect_domain
if request.host == 'appname.heroku.com'
redirect_to "http://yourdomain.tld#{request.request_uri}", :status=>301
end
end
---->8
(big thanx to David from suppport!)
regards
D

Resources