I currently have a Rails app, my_app.comand its associated Wordpress blog blog.my_app.com. They both work independently on Heroku (i.e. without Apache or Nginx scripts)
I am trying to move the blog to a subfolder of the Rails application my_app.com/blog, without losing any of the existing SEO juices on the blog.
I implemented a rendering resident proxy server, and the blog home page dutifully appears at http://my_app.com/blog/will. However, all the links embedded in the blog still point to the subdomain, and not to the folder in the application’s blog.
How to set up blog links on http://my_app.com/blog/post1, not on blog.my_app.com/post1??
My config.ru file:
require ::File.expand_path('../config/environment', __FILE__)
use Rack::ReverseProxy do
reverse_proxy(/^\/blog(\/.*)$/, 'http://my-blog.herokuapp.com$1', opts = {:preserve_host => true})
end
use Rack::Deflater
run MyBlog::Application
In my .rb routes:
constraints domain: 'blog.my_app.com' do
get '(*path)' => 'application#blog'
end
get "/blog" => redirect("/blog/")
In my ApplicationController application:
def blog
redirect_to "http://my_app.com{request.fullpath.gsub('/blog','')}", :status => :moved_permanently
end
WP.htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>