简体   繁体   中英

htaccess redirect third level domain on the main one

I have to solve this simple situation. I have a bunch of third level domain like: oldthirdlevel.example.com that I want to redirect on the main domain that is www.example.com . I've tried with a simple 301 redirect on the file .htaccess but without any success. I would like to redirect every kind of path to the home of main domain for example:

oldthirdlevel.example.com/whatever --> www.example.com
oldthirdlevel.example.com/otherthings --> www.example.com

this is my file:

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^oldthirdlevel.example.com$ [NC]
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]

But I got a 500 Internal Server Error.

if it is about "a bunch". would it be an option to say: when not domain equals www.example.com:

 RewriteCond %{HTTP_HOST} !^www\.example\.tld$ 
 RewriteRule ^.*$ http://www.example.tld/$0 [R=301,L]

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM