All Collections
How-tos
How to redirect sub-directory URL structure to sub-domain URL structure?
How to redirect sub-directory URL structure to sub-domain URL structure?
Edvard avatar
Written by Edvard
Updated over a week ago

If you have changed the URL structure of your GTranslate paid plan from sub-directory to sub-domain (http://example.com/es/http://es.example.com/) and your translated pages were indexed in search engines, it is recommended to redirect the sub-directory URL structure to sub-domain, in order to not loose the indexed content.
To do so:

If you are using Apache web-server  add the following rule on top of other rules in your .htaccess file.

RewriteRule ^([a-z]{2}|ceb|haw|hmn|zh-CN|zh-TW)/(.*)$ http://$1.example.com/$2 [R=301,L,QSA]

If you are using Nginx web-server add the following rule to the "location /" section of your nginx.config file and reload nginx.

rewrite "^/([a-z]{2}|ceb|haw|hmn|zh-CN|zh-TW)/(.*)$" http://$1.example.com/$2 permanent;

Note: Make sure to replace example.com with your domain name before using the rules.

Did this answer your question?