How can I have my blog live at "/blog", under my domain?
WP Engine works best (fastest & most scalable) when your blog is set to run under your domain, or a sub-domain such as blog.mydomain.com.
However, some of our customers want to keep their existing DNS and Apache or nginx server for their main site, and just “mount” us invisibly under a directory of their domain, such as /blog or /articles.
To do that, you configure your existing Apache server to proxy the traffic between the browser and our servers, translating URL paths in the process.
The downside is if your main server goes down, your blog will be unavailable too. Also, latencies will be significantly higher because all traffic is routed via your main server. If you get a surge in traffic, we’ll only be as fast and scalable as your server can be in shuffling the bytes back and forth.
Still, here’s how to do it:
Instructions for Apache
1. MOD_PROXY
Ensure you’ve installed mod_proxy in Apache on your server.
2. Configure Apache
Add the following lines inside your httpd.conf file:
1 2 3 4 5 6 7 8
| ProxyPass /blog http://SITENAME.wpengine.com
ProxyPassReverse /blog http://SITENAME.wpengine.com
# Tell the WP Engine caching system and HTML-post-processing system about the rewrite
RequestHeader set X-WPE-Rewrite "http://www.mydomain.com/blog"
# Enable HTTP keep-alives to significantly reduce network traffic and latency
ProxySet keepalive=On |
Of course you should replace “/blog” with the path you want to mount and “SITENAME” with your account name. Don’t forget these must go under the appropriate VirtualHost section (typically after the Allow/Deny section) if you are using virtual hosts on your server.
Instructions for ngnix
Assumptions for the example code below:
- Your WP Engine account name is “wpename” (e.g. your canonical domain is wpename.wpengine.com)
- You’re wanting to mount your blog on your own server with domain “mydomain.com” and under the path “/blog”.
Create a location section in your nginx configuration like so:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| location /blog {
# Pass along the client's IP address
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# Ensure that cache-control header is passed along
proxy_set_header Cache-Control $http_cache_control;
# Tell the WP Engine caching system and HTML-post-processing system about the rewrite
proxy_set_header X-WPE-Rewrite http://mydomain.com/blog;
# Reverse-rewrite any response Location headers
proxy_redirect default;
# Send traffic to WP Engine
proxy_pass http://wpename.wpengine.com;
} |
3. Configure WordPress
Set the home and siteurl values in your WP database wp_options table to ‘http://SITENAME.wpengine.com’.
4. Pat yourself on the back
Or better yet, pay it forward.
If you run into problems, just let us know. This can be a tricky thing to get right, but it definitely can work!
« Back to the FAQ
Questions answered? Let's get started