Redirect subdomain in .htaccess and use URL to redirect to subdirectory

0

I have a site, say http://es.misitio.com , and I need to use to redirect the URL (using the subdomain to add it as a subdirectory) to http://www.misitio.com/es .

The same for

http://en.misitio.com => http://www.misitio.com/en
http://fr.misitio.com => http://www.misitio.com/fr
http://de.misitio.com => http://www.misitio.com/de

This is what I have:

RewriteCond     %{HTTP_HOST}            ^www.misitio.com$       [NC]
RewriteRule     ^(.*)$               http://www.misitio.com/$1  [R=301,L]
    
asked by Niche 19.10.2018 в 06:42
source

1 answer

1

Previously you should have created a directory where you want your rule redirected. (and with the necessary reading permissions)

You can do the following, in your .htaccess file:

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^piwik.davidcrx.net [NC]
RewriteRule ^(.*)$ https://davidcrx.net/es/ [R=301,L]

I hope it helps;).

PS: I've tried it on my server and it works without problems, you tell me.

    
answered by 19.10.2018 в 14:35