Wordpress Blog Route to Rails Subfolder - Blog Links Unchanged

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>
+4
3

, , , URL- WordPress, . - :

Search: blog.my_app.com
Replace: my_app.com/blog

. WordPress . , .

WordPress. , . , , .

+2

, , mtinsley . , , WordPress, ! WordPress URL- http://my_app.com/blog/.

, . " ". blog.my_app.com/some/post my_app.com/blog/some/post, .

, htaccess WordPress, blog.my_app.com/some/post my_app.com/blog/some/post. , , blog.my_app.com .

0

, , Wordpress. . , , , Wordpress. , -, -: , .

, : https://interconnectit.com/products/search-and-replace-for-wordpress-databases/

It searches and replaces the database, which automatically solves the problem with serialized PHP values ​​that arise if you try to do it yourself. You can limit it to only certain tables, and you can view the changes that it will make before they are executed. Whenever you move a Wordpress installation, use this tool to find the old URL and replace it with the new one.

0
source

All Articles