Using a Reverse Proxy and 301 redirect to appear Sub Domain as Sub Directory - what are the SEO Risks?
-
We’re in process to move WordPress blog URLs from subdomains to sub-directory. We aren’t moving blog physically, but using reverse proxy and 301 redirection to do this.
- Blog subdomain URL is https://blog.example.com/ and
- destination sub-directory URL is https://www.example.com/blog/
Our main website is e-commerce marketplace which is YMYL site. This is on Windows server. Due to technical reasons, we can’t physically move our WordPress blog to the main website.
Following is our Technical Setup
- Setup a reverse proxy at https://www.example.com/blog/ pointing to https://blog.example.com/
- Use a 301 redirection from https://blog.example.com/ to https://www.example.com/blog/ with an exception if a traffic is coming from main WWW domain then it won’t redirect. Thus, we can eliminate infinite loop.
- Change all absolute URLs to relative URLs on blog
- Change the sitemap URL from https://blog.example.com/sitemap.xml to https://www.example.com/blog/sitemap.xml and update all URLs mentioned within the sitemap.
SEO Risk Evaluation
We have individual GA Tracking ID and individual Google Search Console Properties for main website and blog. We will not merge them. Keep them separate as they are.
Keeping this in mind, I am evaluating SEO Risks factors
- Right now when we receive traffic from main website to blog (or vice versa) then it is considered as referral traffic and new cookies are set for Google Analytics. What’s going to happen when its on the same domain?
- Which type of settings change should I do in Blog’s Google Search Console? (A). Do I need to request “Change of Address” in the Blog’s search console property? (B). Should I re-submit the sitemap?
- Do I need to re-submit the blog sitemap from the https://www.example.com/ Google Search Console Property?
- Main website is e-commerce marketplace which is YMYL website, and blog is all about content. So does that impact SEO?
- Will this dilute SEO link juice or impact on the main website ranking because following are the key SEO Metrices. (A). Main website’s Avg Session Duration is about 10 minutes and bounce rate is around 30% (B). Blog’s Avg Session Duration is 33 seconds and bounce rate is over 92%
-
I wrote this on my phone and I will update this in 2-3 hours
rewrite the URLs do not redirect
-
PS
tools like CloudFlare & Fastly don’t care what you’re server is .
https://blog.cloudflare.com/subdomains-vs-subdirectories-best-practices-workers-part-1/
https://blog.cloudflare.com/subdomains-vs-subdirectories-improved-seo-part-2/
https://moz.com/community/q/reverse-proxy-a-successful-blog-from-subdomain-to-subfolder
frontend ssl_in
bind :443 ssl crt /etc/haproxy/website.com.combined
acl root path /
acl blog path_beg /blog
acl sitedomain path_beg /leasopedia
acl glossary path_beg /glossary
acl wpadmin path_beg /wp-
acl blog_search query -m reg ^s=.$
acl blog_preview query -m reg ^p=.*$use_backend wpengine if blog OR sitedomain OR glossary OR wpadmin OR root blog_search OR root blog_preview
default_backend main-sitebackend wpengine
server wpengine examplecompany.wpengine.com:443 ssl ca-file /etc/ssl/certs/ca-certificates.crtbackend main-site
server main-site example.examplecompany.com.:443 ssl ca-file /etc/ssl/certs/ca-certificates.crthttps://blog.examplecompany.com or https://examplecompany.com/blog.
It’s worth noting that WPEngine does not recommend this practice.
For those that want to host at https://site.com/blog and do it with a managed WordPress hosting provider like WPEngine, this article is for you.
(Note, WPEngine will automatically block your reverse proxy, so you will need to contact customer support and ask them to whitelist its IP address in their firewall. I found this to be a painless process thanks to the friendly support staff at WPEngine.)
How?
The trick to getting the blog to look like it’s living on the main site (but actually living elsewhere) is to use a reverse proxy.
HAProxy is a powerful reverse proxy, though its configuration has a bit of a learning curve compared to Nginx or Apache.
We use HAProxy internally because it works well with AWS Elastic Load Balancers, which frequently change their IP address. Learn more
HAProxy config
| 1 | bind *:443ssl crt/etc/haproxy/website.com.combined |
You’ll need to use SSL, as all WPEngine installs redirect to SSL.
Of note is that HAProxy expects your certificate chain and your private key to be combined into one file
| 1 | acl |
These are the pattern matching lines that we’ll use to determine which traffic is forwarded to WPEngine
| 1 |
use_backend wpengine ifblog orsitename ORglossary ORwpadmin ORroot blog_search ORroot blog_preview
|
This directs /blog*, /sitename*, /glossary* and /wp-* to WPEngine.
You can replace these with your own blog and page paths configured in wordpress.
This line also directs /?s= and /?p= to wordpress using the combined root and blog_search and blog_preview lines.
These are necessary to making searching and page previews work in WordPress.
| 1 | default_backend main-site |
Everything that doesn’t match one of the above patterns will go to the main site.
| 1 | backend wpengine |
Directives in the frontend that resolve to this backed will route to the blog.
| 1 | backend main-site |
Directives in the frontend that resolve to this backed will route to your main site.
I would use Fastly
https://thoughtbot.com/blog/host-your-blog-under-blog-on-your-www-domain
https://blog.cloudflare.com/subdomains-vs-subdirectories-best-practices-workers-part-1/
-
Hi I have done this for 20+ websites.
Following is our Technical Setup
- Setup a reverse proxy at https://www.example.com/blog/ pointing to https://blog.example.com/
please remember that the hosting or reverse proxy on the server is so important. Some managed WordPress hosts do this better then others.
https://pressidium.com/ now offers reverse proxy's on all plans for free
if you want to do this with out having to worry about it any problem I cannot stress how easy it is done by hosting the blog on Pagely.com it’s now free!
(don’t worry about the $200 they don’t change it)
https://support.pagely.com/hc/en-us/articles/213148558-Reverse-Proxy-Setup
or kinsta for $50 more a month
https://kinsta.com/knowledgebase/reverse-proxy/
Pantheo.io (my go to host) now offers the “Advanced Global CDN” it lets you run a reverse proxy & much more via Fastly (my favorite CDN) the cost is very reasonable.
https://pantheon.io/product/advanced-global-cdn
Servebolt.com offers reverse proxy & hosts all PHP sites Wordpress too. They use CloudFlare & they will setup everything for you for free. They are also a full enterprise partner
https://servebolt.com/help/article/cloudflare-workers-reverse-proxy/
You can also use Fastly, CloudFlare business, Incapsula, Cloudfront
2. Use a 301 redirection from https://blog.example.com/ to https://www.example.com/blog/ with an exception if a traffic is coming from main WWW domain then it won’t redirect. Thus, we can eliminate infinite loop.
This is something that is very easy I would use Fastly
- Change all absolute URLs to relative URLs on blog
NO don’t do that it will hurt your site & will not help you change the URLs they need to be rewritten not made relative it’s a very bad way of trying to do this and will not help your site.
- Change the sitemap URL from https://blog.example.com/sitemap.xml to https://www.example.com/blog/sitemap.xml and update all URLs mentioned within the sitemap
Our main website is e-commerce marketplace which is YMYL site. This is on Windows server. Due to technical reasons, we can’t physically move our WordPress blog to the main website.
If you’re website site is YMYL I would use Pagely but Linode , AWS can do this to with Fastly or Nginx
https://thoughtbot.com/blog/host-your-blog-under-blog-on-your-www-domain
<code>location /blog/ { proxy_pass https://blog.example.com; 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; }</code>
<code>please let me know if you need help
Tom</code>
Got a burning SEO question?
Subscribe to Moz Pro to gain full access to Q&A, answer questions, and ask your own.
Browse Questions
Explore more categories
-
Moz Tools
Chat with the community about the Moz tools.
-
SEO Tactics
Discuss the SEO process with fellow marketers
-
Community
Discuss industry events, jobs, and news!
-
Digital Marketing
Chat about tactics outside of SEO
-
Research & Trends
Dive into research and trends in the search industry.
-
Support
Connect on product support and feature requests.
Related Questions
-
New Domain, No 301 Possible - Any Advice
A client of mine lost their domain when an ex business partner sold it out from under them. They've filed with WIPO, but in the meantime we're trying to figure out how to help them out. They had two really excellent links - one from the NY Times and one from a .edu website. I'm going to reach out to the authors of those articles (the articles are pretty old, so I doubt they'll change the links), but does anyone have any advice on how to let search engines know the new domain replaces the old without having the ability to do redirects? The content on the site is exactly the same - we were able to get the files over, happily. I've re-submitted the site for indexing, changed the domain links in Moz Local, changed in Analytics, and on all their social sites. Is there anything I'm not thinking of that can be done to let Google know that this new domain replaces the old? Thank you!
Intermediate & Advanced SEO | | newwhy0 -
Looking for SEO advice on Negative SEO attack. Technical SEO
please see this link https://www.dropbox.com/s/thgy57zmmwzodcp/Screenshot 2016-05-31 13.25.23.png?dl=0 you can see my domain is getting tons of chinese spam. I have 410'd the page but it still keeps coming.. 7tnawRV
Intermediate & Advanced SEO | | mattguitar990 -
Redirecting main www. subdomain to new domain. Can you then create a new subdomain on the old domain?
Hi there, The scenario is this: We have been working on a rebrand and have changed the company name So, we want to redirect www.old-name.com to www.new-name.com However, the parent company is retaining the old brand name for corporate purposes So, in an ideal world, we'd be able to keep www.old-name.com active - but clearly that would sacrifice all of the authority built up over the years, so we do have to redirect the main www. subdomain in it's entirity. However - one suggested solution is to redirect www.old-domain.com to www.new-domain.com... but then create a new corporate subdomain: for example, business.old-domain.com business.old-domain.com will not be competing with the new site on any service/product related terms; it will only need to appear in SERPs for the company name I'd appreciate some thoughts on this, as I've not done this before or found any examples of anyone that has. Is that a massive risk in terms of sending a confusing message to Google? Thanks for your help
Intermediate & Advanced SEO | | edlondon0 -
Buying a domain and redirecting it to your website (improves seo?)
hello everyone, imagine that I have a website with Pagerank 7, PA50 DA59... and there is another website who is my competitor... so I decide to buy them... Pagerank3 PA30, DA25.. So I redirect this website to my domain...Using google webmasters I say to Google that it was redirected... So does this improve my SEO or no? Do I get part of the link juice and so on? Can this really improve my rankings?
Intermediate & Advanced SEO | | FCRMediaLietuva0 -
Domain Forwarding for SEO
Hey guys, I recently created a new website for a client who was ranking #1 for the term "jupiter obgyn" but they have now dropped down to #4. This happened because their old home page was at www. instead of just jupiterobgyn.com. When you type in the www. version, it does take you to the root domain but it's not carrying the old PA! The www. version of the page had a 22 PA and the new root domain hosted page is a 1. How can I fix it so that "link juice" carries over? Is this something i need to do in 1and1 (their web host) or within Wordpress? Thanks!!!
Intermediate & Advanced SEO | | RickyShockley0 -
How do you find all of your 301 redirects?
I would like a full list of 301 redirects that we have on our site. Is there a way to export it? I tried Bing Webmaster tools and the list was incomplete. We use IIS. Any ideas?
Intermediate & Advanced SEO | | EcommerceSite0 -
Does using a sub-domain lessen the effectiveness of your main domain?
For example a website without a blog and is a simple html site with no blogging capabilities. We go out to Blogger or Wordpress and set up the blog portion of the website using something like blog.yourdomain.com. Does this make a difference SEO wise? Is is more effective to be sure that you are using the main domain and not a sub-domain? I have heard both sides before but can't seem to find the concrete answer. Thanks for any advise out there.
Intermediate & Advanced SEO | | d25kart0 -
Canonical URL redirect to different domain - SEO benefits?
Hello Folks, We are having a SEO situation here, and hope your support will help us figure out that. Let's say there are two different domains www.subdomian.domianA.com and www.domainB.com. subdomain.domainA is what we want to promote and drive SEO traffic. But all our content lies in domainB. So one of the thoughts we had is to duplicate the domainB's content on subdomian.domainA and have a canonical URL redirect implemented. Questions: Will subdomain.domainA.com get indexed in search engines for the content in domainB by canonical redirect? Do we get the SEO benefits? So is there any other better way to attain this objective? Thanks in advance.
Intermediate & Advanced SEO | | NortonSupportSEO0