You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

在现有Rails Middleman静态网站中整合WordPress博客的方案咨询

How to Map Your WordPress Blog to www.abcd.com/xyz/blog

Absolutely, you’ve got a few solid options to make this happen—let’s break them down based on how much you want to adjust your existing WordPress setup:

Option 1: Reverse Proxy (No WordPress Migration Needed)

This is the most common approach if you want to keep your WordPress instance on blog.xyz.io but serve it under the desired URL. It works by routing requests to www.abcd.com/xyz/blog to your existing WordPress backend, with users never seeing the original blog.xyz.io address.

Steps to set this up:

  1. Configure your web server (e.g., Nginx or Apache)

    • For Nginx, add a location block to your www.abcd.com server config that forwards requests to your WordPress site:
      location /xyz/blog {
          proxy_pass https://blog.xyz.io;
          proxy_set_header Host $host;
          proxy_set_header X-Real-IP $remote_addr;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          proxy_set_header X-Forwarded-Proto $scheme;
      }
      
    • For Apache, enable the mod_proxy and mod_proxy_http modules, then add this to your virtual host config:
      ProxyPass /xyz/blog https://blog.xyz.io
      ProxyPassReverse /xyz/blog https://blog.xyz.io
      
  2. Update WordPress settings

    • Log into your WordPress admin, go to Settings > General
    • Set Site Address (URL) to https://www.abcd.com/xyz/blog
    • Leave WordPress Address (URL) as https://blog.xyz.io (this tells WordPress where its core files are hosted)
    • Save changes, then update your Permalink Settings (just re-save them to flush rewrite rules)
  3. Fix static asset paths (if needed)

    • If images or styles are loading from blog.xyz.io, add this to your wp-config.php file to force relative paths:
      define('WP_HOME','https://www.abcd.com/xyz/blog');
      define('WP_SITEURL','https://blog.xyz.io');
      define('WP_CONTENT_URL', '/xyz/blog/wp-content');
      

Option 2: Migrate WordPress to the Static Site’s Subdirectory

If you prefer to host WordPress directly under www.abcd.com/xyz/blog (instead of proxying), you can migrate your WordPress instance to the same server as your Middleman static site.

Steps for migration:

  1. Backup your WordPress site

    • Export your database via phpMyAdmin or a plugin like UpdraftPlus, and download all WordPress files from blog.xyz.io.
  2. Move files to the target directory

    • On your www.abcd.com server, upload the WordPress files to the /xyz/blog subdirectory of your static site’s root folder.
  3. Update WordPress database and settings

    • Import your database backup to a new database (or the same one if your server supports it)
    • Run SQL queries to replace all instances of blog.xyz.io with www.abcd.com/xyz/blog:
      UPDATE wp_options SET option_value = REPLACE(option_value, 'https://blog.xyz.io', 'https://www.abcd.com/xyz/blog') WHERE option_name IN ('siteurl', 'home');
      UPDATE wp_posts SET post_content = REPLACE(post_content, 'https://blog.xyz.io', 'https://www.abcd.com/xyz/blog');
      UPDATE wp_postmeta SET meta_value = REPLACE(meta_value, 'https://blog.xyz.io', 'https://www.abcd.com/xyz/blog');
      
    • Update wp-config.php to use the new database credentials, and set both WP_HOME and WP_SITEURL to https://www.abcd.com/xyz/blog.
  4. Configure your web server

    • Ensure your server is set up to process PHP requests for the /xyz/blog directory (since your main site is static Middleman files, you’ll need to override the static file handling for this path). For Nginx, that might look like:
      location /xyz/blog {
          root /path/to/your/static/site/root;
          index index.php index.html;
          try_files $uri $uri/ /xyz/blog/index.php?$args;
      
          location ~ \.php$ {
              fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
              fastcgi_index index.php;
              fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
              include fastcgi_params;
          }
      }
      

Option 3: Integrate via WordPress REST API (For Deep Customization)

If you want the blog to match your Middleman site’s design perfectly, you can pull content from WordPress using its REST API and generate static blog pages directly in Middleman. This way, visitors see fully static content, but marketers still use WordPress to publish.

High-level steps:

  1. Enable WordPress REST API (it’s enabled by default in WordPress 4.7+)
  2. Add code to your Middleman project to fetch posts from https://blog.xyz.io/wp-json/wp/v2/posts
  3. Generate static pages in Middleman for the blog index (/xyz/blog) and individual post pages (/xyz/blog/post-slug)
  4. Style the generated pages to match your existing Middleman site’s design

This approach requires some Ruby/Rails experience to build the integration, but it gives you full control over the user experience.

Important Notes

  • Always test changes in a staging environment first to avoid breaking your live site.
  • Make sure your SSL certificate covers www.abcd.com (it should already, but double-check that the /xyz/blog path is included).
  • If you use a CDN, clear your cache after making changes to ensure visitors see the new URL structure.

内容的提问来源于stack exchange,提问作者Bhavan Kuchibhotla

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.26 11:00:08