Skip to main content
All CollectionsSEO
SEO for Nginx
SEO for Nginx
Ishai Jaffe avatar
Written by Ishai Jaffe
Updated over 7 years ago

Follow this guide to make your translated website is SEO-friendly.

  1. Log-in to your server FTP/SSH

  2. Locate the nginx configuration file in your server. This is usually in /etc/nginx/sites-available

  3. Modify the Nginx configuration file that handles your server with Bablic's code:

Let's assume you have a configuration file called default that looks like this:

server {
   listen 80;
   root /usr/share/nginx/html;
   index index.html index.htm;

   location / {
         try_files $uri $uri/ /index.html;
   }    
}

Modify the conf file so it will look like this:

proxy_cache_path /tmp levels=1:2 keys_zone=my_cache:10m max_size=10g inactive=60m ;
proxy_cache_valid 200 5760m;
proxy_cache_valid 404 301 302 5m;
proxy_cache_key "$host$request_uri";

server {
   listen 80;
   # SET BABLIC SITE ID
   set $bablic_id [INSERT BABLIC SITE ID HERE];
   add_header x-bablic-id $bablic_id;
   # Standard Web Server Settings - replace this code with your regular webserver settings
   root /usr/share/nginx/html;
   index index.html index.htm;
   # End of Standard Web Server Settings

   # Un comment this code if you wish to use subfolders. In this example the subfolders are 'es' for Spanish and 'de' for German.
   # This can be changed according to each website languages
   #location ~ ^/(es|de)/ {
   #        if ($http_user_agent ~ (bot|crawler|baiduspider|80legs|mediapartners-google|adsbot-google)) {
   #           set $bablic_original_uri $scheme://$host$request_uri;
   #           rewrite .* /_bablicrewrite?;
   #        }
   #        rewrite ^/(?:es|de)/(.*)$ /$1;
   #
   # }    

   location / {
         if ($http_user_agent ~ (bot|crawler|baiduspider|80legs|google|facebook|twitter|seo)) {
            set $bablic_original_uri $scheme://$host$request_uri;
            rewrite .* /_bablicrewrite?;
         }
         # Standard file handler    
         try_files $uri $uri/ /index.html;
         # End Standard file handler
   }    

   location /_bablicrewrite{
      proxy_method POST ;
      proxy_ignore_headers X-Accel-Expires Expires Cache-Control Set-Cookie;
      proxy_set_header Content-Length 0;
      proxy_set_header X-Bablic-ID $bablic_id;
      proxy_set_header X-Original-URI $bablic_original_uri;
      proxy_pass http://seo.bablic.com/api/engine/seo;
      proxy_cache my_cache;
      expires 96h;
   }
}

Reload the Nginx process to make the new changes work:

sudo /etc/init.d/nginx reload

To activate Sub-Directories uncomment the sub-directories line and replace the language codes with the languages codes you use in your Bablic account.

That's it, you can click "Verify" in your Bablic SEO Configuration Wizard.

Did this answer your question?