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
-
Should we use a separate domain for franchise recruitment?
I represent a franchisor and we have two marketing campaigns: attracting customers to purchase our service; and attracting potential franchisees to purchase our business. We're torn between simply putting franchise-related content on our existing consumer website, or building a completely separate website for franchise recruitment. Building a completely separate site would involve a separate SEO strategy to build domain authority and backlinks... so we're thinking the better strategy would be to simply piggyback off of our already existing consumer website. Any advice?
Intermediate & Advanced SEO | | kimberleymeloserpa0 -
Clarity needed on 301 redirects
Looking to get a bit of clarity on redirects: We're getting ready to launch a new website with a simplified url structure (we're consolidating pages & content) & I already know that I'll have to employ 301 redirects from the old url structure to the new. What I'm not clear about is how specifc I should be. Here's an example of my file structure: Old website: www.website.com
Intermediate & Advanced SEO | | JSimmons17
New website: www.website.com Old website: www.website.com/vacations
New website: www.website.com/vacations Old website: www.website.com/vacations/costa-rica
New website: www.website.com/vacations/central-america Old website: www.website.com/vacations/costa-rica/guanacaste
New website: www.website.com/vacations/central-america Old website: www.website.com/vacations/mexico
New website: www.website.com/vacations/central-america Old website: www.website.com/vacations/mexico/cancun
New website: www.website.com/vacations/central-america Old website: www.website.com/vacations/bolivia
New website: www.website.com/vacations/south-america Old website: www.website.com/vacations/bolivia/la-paz
New website: www.website.com/vacations/south-america Do I need to redirect each and every page or would just redirecting just the folder be enough to keep my SEO juice? Many thanks in advance for any help!0 -
301 Redirection problems
A couple of days ago we did a restructure of our e-commerce site (wordpress + woocomerce) where some product categories needed to change names. I used Yoast SEO plugin to do 301 redirects in the .htaccess file.Today I noticed that we had two hits in the SERP on the phrase "dildos med vibrator". See the attached screenshot (first two results).One goes to http://www.oliverocheva.se/kategori/sexleksaker/dildos/dildos-med-vibrator/ which is the right URL. One goes to http://www.oliverocheva.se/kategori/sexleksaker/dildosdildos-med-vibrator-dildos-for-honom/ which is a corrupt URL that has never been in use. The old one we did a redirect from was /kategori/for-honom/dildos-for-honom/dildos-med-vibrator-dildos-for-honom/The command in the .htaccess file was: Redirect 301 /kategori/for-honom/dildos-for-honom/dildos-med-vibrator-dildos-for-honom/ http://www.oliverocheva.se/kategori/sexleksaker/dildos/dildos-med-vibratorWhat has happened here? Why does the 301 create entirely new URL:s in the SERP?Tz0TULT.png
Intermediate & Advanced SEO | | kisen0 -
Using Webmaster Tools to Redirect Domain to Specific Page on Another Domain
Hey Everyone, we redirected an entire domain to a specific URL on another domain (not the homepage). We used a 301 Redirect, but I'm also wondering if I should use the Google Webmaster Tools "Change of Address" section to redirect. There is no option to redirect the old domain to the specific URL on the new domain within the "Change of Address" section. Thoughts?
Intermediate & Advanced SEO | | M_D_Golden_Peak0 -
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 -
301 redirect and improved ranking
I was wondering if a 301 redirect will improve my ranking. My subpages use to redirect to my homepage ( all the subpages of my site redirecting to my homepage) and my homepage use to have no redirect from non www.to www. ( other than thru google webmaster tools. I am sure why it was like this for my subpages... I was wondering if I can expect some improvements in ranking now that the redirect goes from the none www. to the www version of each subpage and not to the homepage. By the way what was the issue ( was I telling google ) by re-directing all my subpages to the homepage ? was I making google think that my subpages and my homepage were all the same ? was I sending all the link juice from the subpages to my homepage ? etc... Thank you,
Intermediate & Advanced SEO | | seoanalytics0 -
301 Redirect to a new domain, Need linkbuilding ideas
Hi, I just 301 redirected my 3 year old domain to a new domain which was created yesterday. Now i want to start link building to my new domain. Should i start slowly by publishing 4-5 articles on article directories and a 1 press release a week? Can someone suggest me some ideas on how to handle a new domain. Will be waiting for replies.
Intermediate & Advanced SEO | | Dex3783783780 -
Cross Sub Domain Canonical Links
I currently have 1 website, but am planning on dividing it into sub-domains specific to geographic locations such as xxx.co.uk, xxx.it, xxx.es, etc... We are working on creating original content for the sub-sites, however upon launch many will be duplicate pages. Is there a problem with cross sub-domain canonical links? Thanks!
Intermediate & Advanced SEO | | theLotter0