Hussain Fakhruddin
Hussain Fakhruddin

Reputation: 3272

Apache .htaccess redirect subdomain to parent domain

I want to redirect my subdomain

http://xyz.domain.com to http://domain.com

and similarly any subdirectories like

http://xyz.domain.com/abc to http://domain.com/abc

I don't want redirection for all my subdomains but specifically for this one.

Thanks for the help

Upvotes: 3

Views: 11504

Answers (2)

Meetai.com
Meetai.com

Reputation: 6928

Simplest way of redirecting a subdirectory to a domain:

RedirectMatch 301 ^/subdir/$  http://example.com$1

Upvotes: 0

Clodoaldo Neto
Clodoaldo Neto

Reputation: 125204

RewriteCond %{HTTP_HOST} ^xyz\.domain\.com$
RewriteRule ^/(.*) http://domain.com/$1 [redirect,last]

Upvotes: 5

Related Questions