Home Blog redirection to directory in Heroku app is not working for blog post urls
Reply: 1

Blog redirection to directory in Heroku app is not working for blog post urls

AlphaNico
1#
AlphaNico Published in 2018-01-12 13:05:17Z

I followed this tutorial in order to redirect my blog hosted on a subdomain (blog.botletter.com) to a directory of my Heroku rails app (https://www.botletter.com/blog/).

The redirection works for the main page of the blog (/blog/) but does not for the articles URLs.

I guess it's a problem of configuration within the Rails app but I can't find the mistake. Here is the log in Heroku:

at=info method=GET path="/blog/invite-team-members/" host=www.botletter.com request_id=23b81c9a-e20b-4261-aea4-87adfb781554 fwd="195.154.32.17" dyno=web.1 connect=0ms service=412ms status=500 bytes=725 protocol=https

Here is my config.ru file (I don't use username and passwork like in the tutorial as the blog is not using any access restriction):

require_relative 'config/environment'

use Rack::ReverseProxy do
  reverse_proxy /^\/blog(\/.*)$/, 'https://blog.botletter.com$1', :timeout => 500, :preserve_host => true
end

run Rails.application

My routes:

get '/blog' => redirect("https://www.botletter.com/blog/")
get '(*path)', to: 'application#blog', constraints: { subdomain: 'blog' }

My "blog" action in the application controller:

def blog
    redirect_to "https://www.botletter.com/blog#{request.fullpath.gsub('/blog','')}", :status => :moved_permanently
  end

Thanks for your help!

Phong Phan
2#
Phong Phan Reply to 2018-01-14 02:53:08Z

at=info method=GET path="/blog/invite-team-members/" host=www.botletter.com

I see subdomain is www

get '(*path)', to: 'application#blog', constraints: { subdomain: 'blog' }

You're restring subdomain to be blog, so you need add the subdomain to your blog's path.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.327512 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO