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
-
Redirection of 100 domain to Main domain affects SEO?
Hi guys, An email software vendor managed by a different area of my company redirected 100 domains used for unsolicited email campaigns to my main domain. These domains are very likely to get blacklisted at some point. My SEO tool now is showing me all those domains as "linking" to my main site as do-follow links. The vendor states that this will not affect my main domain/website in any way. I'm highly concerned. I would appreciate your professional opinion about this. Thanks!!
Intermediate & Advanced SEO | | anagentile0 -
301 redirects and impact on page authority
I need to restructure a section of my website, changing some page titles and moving some pages to other sections. This will then change the URLs but the CMS I use will automatically create 301 redirects so the old URLs still work. The question is, will this have any negative impacts on page authority/page rank? From what I've read, it seems having 301's used to have a negative impact but doesn't anymore?
Intermediate & Advanced SEO | | ciehmoz0 -
301 Redirect and Loss of PA and DA
Mozzers, http:itsgr82bme.com Old domain homepage had a DA of 24 and a PA of 36 Currently redirected to http://thekidstime.com Homepage shows a DA of 6 and a PA of 1. That is a significant loss of authority. I thought a 301 is supposed to be better than that. What gives? What are the next steps, asking the old backlinks to update their links? Thanks for your help, Matt
Intermediate & Advanced SEO | | matt.nails0 -
301 redirect to a temporary URL
Hi there, What would happen if I redirected a set of URLs to a temporary URL structure. And then a few weeks later redirected the original URLs and temporary URLs to the final permanent URLs? So for example:A -> B for a few weeks.
Intermediate & Advanced SEO | | sichristie
then: A->C and B->C where:
C is the final destination URL.
B is the temporary destination
A is the original URL. The reason we are doing this is the naming of the URLs and pages are different, and we wish to transition our customers carefully from old to new. I am looking for a pure technical response.
Would we lose link juice? Does Google care if we permanently redirect to a set of 'temporary' URLs, and then permanently redirect to a set of what we think are permanent URLs? Cheers, Simon0 -
Is it safe to 301 redirect old domain to new domain after a manual unnatural links penalty?
I have recently taken on a client that has been manually penalised for spammy link building by two previous SEOs. Having just read this excellent discussion, http://www.seomoz.org/blog/lifting-a-manual-penalty-given-by-google-personal-experience I am weighing up the odds of whether it's better to cut losses and recommend moving domains. I had thought under these circumstances it was important not to 301 the old domain to the new domain but the author (Lewis Sellers) comments on 3/4/13 that he is aware of forwards having been implemented without transferring the penalty to the new domain. http://www.seomoz.org/blog/lifting-a-manual-penalty-given-by-google-personal-experience#jtc216689 Is it safe to 301? What's the latest thinking?
Intermediate & Advanced SEO | | Ewan.Kennedy0 -
Do i need to set up a reverse proxy?
Ahoy all, just through another audit - we have a terrible CMS which is ecommerce based only which doesnt allow us to blog or write much content, we have our blog as a seperate WP in our ftp panel and comes up as www.palicomp.co.uk/blog and our site is www.palicomp.co.uk - my question is do i need to set up a reverse proxy so this is classed as one site and my blog provides more value or would it only matter if it was set up as blog.palicomp.co.uk? Many thanks, Chris
Intermediate & Advanced SEO | | palicomp0 -
301 redirect on Windows IIS. HELP!
Hi My six-year-old domain has always existed in four forms: http://www**.**mydomain.com/index.html http://mydomain.com/index.html http://mydomain.com/ http://www.mydomain.com My webmaster claims it’s “impossible” to do a 301 redirect from the first three to the fourth. I need simple instructions to guide him. The site’s hosted on Windows running IIS Here’s his rationale: These are all the same page, so they can’t redirect to themselves. Index.html is the default page that loads automatically if you don’t specify a page. If I put a redirect into index.html it would just run an infinite redirect loop. As you can see from the IIS set up, both www.mydomain and mydomain.com point to the same location ( VIEW IMAGE HERE ) _Both of these use index.html as the default document ( VIEW IMAGE 2 HERE ) _
Intermediate & Advanced SEO | | Jeepster0 -
Redirect non www. domain to WWW. domain for established website?
Hey guys, The website in question has been online for more than 5 years but there are still 2 versions of the website. Both versions are indexed by Google and of course, this will result in duplicate content. Is it necessary to redirect the non-www domain to the www. domain. What are the cons and advantages? Will a lot of organic traffic be lost at first (if non-www are getting a good amount of traffic)? Thanks.
Intermediate & Advanced SEO | | BruLee0