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
-
Does using a hash menu system drive SEO power to my sub-pages?
My website (a large professional one) uses a interesting menu system. When a user hovers over text (which is not clickable), then a larger sub-menu appears on the screen, when they hover over something else, then this sub-menu changes or disappears. This menu is driven by a hash(#), which makes me wonder. I this giving my sub-pages an SEO kick? Or... is there another way that we should be doing this in order to get that SEO kick?
Intermediate & Advanced SEO | | adamorn0 -
Do you see any SEO risk here?
Hi, I’m seeking your opinion regarding the issue we are facing during rebranding
Intermediate & Advanced SEO | | EnglishtownSEO0 -
Sub-domain or not???
Hi, We're setting up a forum for our users (our target audience responds extremely well to forums). I was wondering if it should be set up on a sub-domain or not. I'm leaning towards sub-domain, but our devs say this will impact how they approach it so I'd like to give them an answer asap so we can proceed with planning it! Thanks, Amelia
Intermediate & Advanced SEO | | CommT0 -
International SEO Domain Structure
Hi Guys, I am wondering if anybody can point me to a recent trusted report or study on international domain name structure and SEO considerations. I am looking to read up on the SEO considerations and recommendations for the different domain structures in particular using sub-directories i.e. domain.com/uk, domain.com/fr. Kind regards,
Intermediate & Advanced SEO | | WeAreContinuum
Cian1 -
Do I redirect pages that no longer appear on the website?
Here is an example of the link that is no longer on the website (Broken link) http://www.weddingrings.com/item.cfm?str_shortdesc=UNIQUE The broken link was fixed to : http://www.weddingrings.com/item.cfm?str_shortdesc=UNIQUE CARRE CUT DIAMOND ETERNITY BAND&str_category=Diamond-Bands-and-Gold-Rings&grouping_id=9&category_id=21&int_item_id=6884 Would I still need to redirect the old broken link to the new fixed one using 301 redirect?
Intermediate & Advanced SEO | | alexkatalkin0 -
Probelms w/ 301 Redirects
I am trying to 301 redirect my old site to the new site (under the same domain. Most of the 404 urls are 301 redirects from 404 pages but they are still able to redirect. I need help understanding why I cannot redirect half of my list. <colgroup><col width="636"> <col width="342"> <col width="64"></colgroup>
Intermediate & Advanced SEO | | Melia
| OLD URL | 301 To: | Status |
| http://www.meliacaribetropical.com/en/groups.html | http://www.meliacaribetropical.com/en/groups.html | done |
| http://www.meliacaribetropical.com/entertainment/ | http://www.meliacaribetropical.com/en/services.html | done |
| http://www.meliacaribetropical.com/es/all_inclusive.html | http://www.meliacaribetropical.com/es/index.html | done |
| http://www.meliacaribetropical.com/es/galeria/ | http://www.meliacaribetropical.com/es/visor.html | done |
| http://www.meliacaribetropical.com/es/los-picapiedra/ | http://www.meliacaribetropical.com/es/index.html | done |
| http://www.meliacaribetropical.com/es/outside-us-telephone-listing.php | http://www.meliacaribetropical.com/en/index.html | done |
| http://www.meliacaribetropical.com/es/restaurantes/ | http://www.meliacaribetropical.com/es/gastronomia.html | done |
| http://www.meliacaribetropical.com/es/reuniones-eventos/ | http://www.meliacaribetropical.com/es/grupos.html | done |
| http://www.meliacaribetropical.com/es/spa/ | http://www.meliacaribetropical.com/es/servicios.html | done |
| http://www.meliacaribetropical.com/es/terms-condition.php | http://www.meliacaribetropical.com/es/index.html | done |
| http://www.meliacaribetropical.com/gallery/beach.html | http://www.meliacaribetropical.com/en/index.html | done |
| http://www.meliacaribetropical.com/gallery/dining.html | http://www.meliacaribetropical.com/en/gastronomy.html | done |
| http://www.meliacaribetropical.com/gallery/pools.html | http://www.meliacaribetropical.com/en/index.html | done |
| http://www.meliacaribetropical.com/lowest-rate.php | http://www.meliacaribetropical.com/en/index.html | done |
| http://www.meliacaribetropical.com/press/ | http://www.meliacaribetropical.com/en/index.html | done |
| http://www.meliacaribetropical.com/spanish/ | http://www.meliacaribetropical.com/es/index.html | done |
| http://www.meliacaribetropical.com/spanish/services/ | http://www.meliacaribetropical.com/en/services.html | done |
| http://www.meliacaribetropical.com/spanish/services/ | http://www.meliacaribetropical.com/es/servicios.html | done |
| http://www.meliacaribetropical.com/terms-condition.php | http://www.meliacaribetropical.com/en/index.html | done |
| http://www.meliacaribetropical.com/es/galeria/piscinas.html | http://www.meliacaribetropical.com/es/index.html |
|
| http://www.meliacaribetropical.com/es/galeria/playa.html | http://www.meliacaribetropical.com/es/index.html |
|
| http://www.meliacaribetropical.com/es/galeria/restaurantes.html | http://www.meliacaribetropical.com/es/gastronomia.html |
|
| http://www.meliacaribetropical.com/es/prensa/ | http://www.meliacaribetropical.com/es/index.html |
|
| http://www.meliacaribetropical.com/es/prensa/family-facilities-amenities.html | http://www.meliacaribetropical.com/es/index.html |
|
| http://www.meliacaribetropical.com/es/prensa/melia-caribe-tropical-announces-fall-promotion.html | http://www.meliacaribetropical.com/es/index.html |
|
| http://www.meliacaribetropical.com/es/prensa/melia-international-brand-overhaul.html | http://www.meliacaribetropical.com/es/index.html |
|
| http://www.meliacaribetropical.com/press/family-facilities-amenities.html | http://www.meliacaribetropical.com/en/index.html |
|
| http://www.meliacaribetropical.com/press/melia-caribe-tropical-announces-fall-promotion.html | http://www.meliacaribetropical.com/en/index.html |
|
| http://www.meliacaribetropical.com/press/melia-international-brand-overhaul.html | http://www.meliacaribetropical.com/en/index.html |
|
| http://www.meliacaribetropical.com/spanish/accommodations/ | http://www.meliacaribetropical.com/es/habitaciones.html |
|
| http://www.meliacaribetropical.com/spanish/dining/ | http://www.meliacaribetropical.com/es/gastronomia.html |
|
| http://www.meliacaribetropical.com/spanish/entertainment/ | http://www.meliacaribetropical.com/es/servicios.html |
|
| http://www.meliacaribetropical.com/spanish/events/ | http://www.meliacaribetropical.com/es/index.html |
|
| http://www.meliacaribetropical.com/spanish/flintstones/ | http://www.meliacaribetropical.com/es/index.html |
|
| http://www.meliacaribetropical.com/spanish/gallery/ | http://www.meliacaribetropical.com/es/visor.html |
|
| http://www.meliacaribetropical.com/spanish/gallery/beach.html | http://www.meliacaribetropical.com/es/index.html |
|
| http://www.meliacaribetropical.com/spanish/gallery/dining.html | http://www.meliacaribetropical.com/es/gastronomia.html |
|
| http://www.meliacaribetropical.com/spanish/gallery/pools.html | http://www.meliacaribetropical.com/es/index.html |
|
| http://www.meliacaribetropical.com/spanish/press/ | http://www.meliacaribetropical.com/es/index.html |
|
| http://www.meliacaribetropical.com/spanish/press/melia-caribe-tropical-announces-fall-promotion.html | http://www.meliacaribetropical.com/es/index.html |
|
| http://www.meliacaribetropical.com/spanish/press/melia-international-brand-overhaul.html | http://www.meliacaribetropical.com/es/index.html |
|
| http://www.meliacaribetropical.com/spanish/royal/ | http://www.meliacaribetropical.com/es/servicio-real.html |
|
| http://www.meliacaribetropical.com/spanish/sitemap.html | http://www.meliacaribetropical.com/es/index.html |
|
| http://www.meliacaribetropical.com/spanish/spa/ | http://www.meliacaribetropical.com/es/servicios.html |
| gastronomia.html0 -
Reversing 301 Re-Directs
What's your philosophy on reversing 301 redirects? Does it depend on how long the redirect has been in place? Is it okay to implement a 301 redirect and remove it if the desired results aren't achieved? Also, what about multiple 301 redirects and removing those? I'm working with a site that has several 301 redirects in place and there's no definite knowledge as to when these were placed. I know there's always a danger and the possibility of unintended results when moving these around. I'm just curious as to what others' experience has been with placing and removing these either within a short period of time or over the course of as much as a year. Thanks in advance!
Intermediate & Advanced SEO | | JamieCottle280 -
Where do I redirect a domain to strengthen another domain?
I've got a UK domain that I need to redirect to a US domain. Should I point it to the root domain or a landing page off the root and what it the benefit to doing one over the other?
Intermediate & Advanced SEO | | JCorp0