Did you know that the SEO of your domain can be improved by switching from subdomains to directory paths? Link to heading
The issue with subdomains is that each one has its own domain rating and requires a separate set of do-follow backlinks. This approach is tedious and inefficient, especially when you could instead consolidate your efforts to boost your main domain using different content like blogs, tools, services, and other pages routed through directory paths.
Here’s an example to clarify:
Imagine you have several sections, such as /blog
, /tools
, and /services
, and your main domain is website.com
. You want your main page to rank #1 on Google for specific keywords. The more content you have and the more do-follow links pointing to your domain, the better your chances of being discovered.
Now, let’s say you create a blog at blog.website.com. With a subdomain, all backlinks and keyword indexing for the blog are separate from your main domain, effectively splitting your SEO efforts. This is a waste of resources. Instead, you can use directory paths and make your blog accessible at website.com/blog
. This approach consolidates all SEO benefits under your main domain.
But what if your blog and your main landing page are two separate web applications or pages?
Here’s how you can achieve this using a simple Nginx configuration with location blocks and proxy_pass:
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
location / { # root is your website.com
root /var/www/your-website; # Replace this with the path to your static site's root directory
index index.html index.htm;
try_files $uri $uri/ =404;
}
location /blog/ {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_pass http://127.0.0.1:8080;
proxy_redirect off;
}
location /services/ {
alias /var/www/tools/dist/; # for e.g. generated static pages of your services
index index.html index.htm;
try_files $uri $uri/ =404;
}
location /tools/ {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_pass http://172.10.0.1:8080; # internal ip of your docker hosted application
}
location = /blog {
return 301 /blog/;
}
location = /services {
return 301 /services/;
}
location = /tools {
return 301 /tools/;
}
}
And that’s it, happy coding.
By the way there’s an amazing tool for checking uptime of your websites and services called BetterStack checkout for .e.g. status page of one of my projects
and its free to start. You can see full list of tools I use in Tools section.