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://mza.bundledseo.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>
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
-
Deep linking with redirects & building SEO
Hi there. I'm using deep linking with unique URL's that redirect to our website homepage or app (depending on whether the user accesses the link from an iphone or computer) as a way to track attribution and purchases. I'm wondering whether using links that redirect negatively affects our SEO? Is the homepage still building SEO rank despite the redirects? I appreciate your time & thanks for your help.
Intermediate & Advanced SEO | | L_M_SEO0 -
Unintentional wildcard 301 Redirect?
I have migrated a client's site to a new domain. I used Yoast tools to add 301 redirects for all active site pages from old domain to new domain in the .htacces files as neither the client nor I have access to hosting server via FTP (long story). Redirects are working as I intended, and we didn't lose too much in our rankings. Unfortunately, as soon as I saved the .htaccess file in Yoast, old-domain.net/wp-admin began redirecting to new-domain.net/wp-admin. I can no longer login to the wordpress site on the old domain. I did not enter a redirect for /wp-admin. Any thoughts on how this is happening or if there is some other way to get back in? Without server access, I'm pretty stumped. Thanks!
Intermediate & Advanced SEO | | c_estep_tcbguy0 -
How to do a site migration followed by a domain migration and avoid 301 redirect chains?
Hi all, The current roadmap for our Eng team has us performing a site migration (redirecting one subfolder to another subfolder) and then a domain migration shortly after. The way I see it, I have 2 scenarios (the 1st involves the site migration THEN the domain migration and the 2nd is the site migration and domain migration being done simultaneously): olddomain.com/subfolder-old to olddomain.com/subfolder-new THEN olddomain.com/subfolder-new to newdomain.com/subfolder-new AND olddomain.com/subfolder-old to newdomain.com/subfolder-new olddomain.com/subfolder-old to newdomain.com/subfolder-new I also understand that there are two best practices for a domain migration and they are 1) keep everything the same that you can to help Google understand it is the same page, just on a different domain and 2) avoid chain redirects. As you can imagine, scenario 1 requires more Eng costs than scenario 2. So, my question is, is scenario 2 a perfectly viable option or should I make the push to go for scenario 1? Any advice is greatly appreciated!
Intermediate & Advanced SEO | | brad-causes1 -
301 Redirect To Another 301 Redirect
Hi, We have a client with an old domain that they want to redirect to their primary domain. They also have a few older domains pointing to the old domain. Do you recommend leaving them as redirects that point to the old domain? This will create a redirect to a redirect situation. Or, is it better to go ahead and redirect those older domains to the primary one's, removing one layer of redirect? Thank you! Jessie
Intermediate & Advanced SEO | | JessieT0 -
301 redirect with /? in URL
For a Wordpress site that has the ending / in the URL with a ? after it... how can you do a 301 redirect to strip off anything after the / For example how to take this URL domain.com/article-name/?utm_source=feedburner and 301 to this URL domain.com/article-name/ Thank you for the help
Intermediate & Advanced SEO | | COEDMediaGroup0 -
For a mobile website, is it better to use a 301 vs. a 302 redirect?
We are vetting a vendor for our mobile website and they are recommending using a 302 redirect with rel=canonical vs. a 301 redirect due to 301 caching issues. All the research I've done shows that a 301 is by far the better way to go do to proper indexing, which in turn will enhance our page authority. Thoughts on why a 302 would be a better fit than a 301 on our mobile site?
Intermediate & Advanced SEO | | seohdsupply1 -
Redirect 301 or Canonical.
Hello all, I have a page with a long post title and url path name (more than 70 caracters and 115). This page has many visits but I am changing the SEO website structure according to SEOMOz and forums guidelines so: I WILL CREATE A DUPLICATE PAGE WITH THE SAME INFO. This issue has been marked as an issue in the SEO tools, for long names>70 and url path names>115 My question is which option should I use and you would recommend me? 1. OPTION 1: Ideally I would like to keep the old post, so I should use the canonical tag, but my main concern is if the search engines in terms of SEO, even the canonical has been done, will penalise my SEO as there is still a post with bad SEO optimising, or if this is not the case because I already used the canonical. 2. OPTION 2: Eliminate the post and redirection 301 to the new page to keep the juice. I would prefer option 1, as I keep both post and page, but only if searchengines do not penalise my SEO as they detect a long post name and url path name. Thank you verty much, Antonio
Intermediate & Advanced SEO | | aalcocer20030 -
All page files in root? Or to use directories?
We have thousands of pages on our website; news articles, forum topics, download pages... etc - and at present they all reside in the root of the domain /. For example: /aosta-valley-i6816.html
Intermediate & Advanced SEO | | Peter264
/flight-sim-concorde-d1101.html
/what-is-best-addon-t3360.html We are considering moving over to a new URL system where we use directories. For example, the above URLs would be the following: /images/aosta-valley-i6816.html
/downloads/flight-sim-concorde-d1101.html
/forums/what-is-best-addon-t3360.html Would we have any benefit in using directories for SEO purposes? Would our current system perhaps mean too many files in the root / flagging as spammy? Would it be even better to use the following system which removes file endings completely and suggests each page is a directory: /images/aosta-valley/6816/
/downloads/flight-sim-concorde/1101/
/forums/what-is-best-addon/3360/ If so, what would be better: /images/aosta-valley/6816/ or /images/6816/aosta-valley/ Just looking for some clarity to our problem! Thank you for your help guys!0