Mobile app version of vmapp.org
Login or Join
Kevin317

: Help with 301 redirect from subdomain to root domain I need to forward existing subdomain links to the root domain as the subdomain no longer exists. I have tried so many different lines of

@Kevin317

Posted in: #301Redirect #Apache #Htaccess

I need to forward existing subdomain links to the root domain as the subdomain no longer exists. I have tried so many different lines of code in my .htaccess file and can not get the redirect to work.

The links to the subdomain look like: sub.example.com/dir/y99bb4
Can anyone suggest any code for me?

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Kevin317

1 Comments

Sorted by latest first Latest Oldest Best

 

@Harper822

To redirect requests for sub.example.com/uri to example.com/uri:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^sub.example.com$
RewriteRule ^(.*)$ example.com/ [R=301,L]


To redirect requests for sub.example.com/uri to example.com:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^sub.example.com$
RewriteRule ^(.*)$ example.com/ [R=301,L]

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme