I have a website incorrectly indexed on Google, like this: www.mysite.fr/de-DE/mypage
I need to fix it, with a 301 redirect to www.mysite.de/de-DE/mypage To put it simple, the first level domain (.it, .de, fr...) should correspond to the second url parameter (it-IT, de-DE, fr-FR...). How can I do it using .htaccess only?
You can use this code in your DOCUMENT_ROOT/.htaccess
file:
RewriteEngine On
RewriteCond %{REQUEST_URI}::%{HTTP_HOST} ^/([a-z]{2})-.*?::(?:www\.)?mysite\.\1$ [NC]
RewriteRule . http://www.mysite.%1%{REQUEST_URI} [R=302,L,NE]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.