I have multiple subdomains, for example:
uk.domain.com
us.domain.com
eu.domain.com
And I need to redirect all of these subdomains (and any pages that the user tries to access on those subdomains) to:
www.domain.com
Example:
uk.domain.com/page1 -> www.domain.com/page1
uk.domain.com/page2 -> www.domain.com/page2
us.domain.com/page1 -> www.domain.com/page1
us.domain.com/page2 -> www.domain.com/page2
eu.domain.com/page1 -> www.domain.com/page1
eu.domain.com/page2 -> www.domain.com/page2
...etc
Is there a rule that can apply to all URLs on each of the subdomains and redirect them to the main domain, with the page in the URL intact, as above?
I have tried example here , but that did not work
Solved. This works
RewriteCond %{HTTP_HOST} ^uk\.something\.com$ [NC]
RewriteCond %{REQUEST_URI} !^/?$ [NC]
RewriteRule ^(.*)$ https://www.somethingelse.com/$1 [R=301,L]
However it needed to be at the top of my .htaccess, since I had other rules that were interfering with it.
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.