简体   繁体   中英

only main Subdomain redirect to main domain through .htaccess

I want to redirect only main subdomain like http://dl.domain.com to domain.com

but not redirect files or script links to main domain.

http://dl.domain.com/123.zip http://dl.domain.com/zippy.zip etc

How I can do this with .htaccess rules?

I use these .htaccess rules but problem not solve

RewriteCond %{HTTP_HOST} ^(www\.)?subdomain\.domain\.com$ [NC]
RewriteRule !^xyz\.php($|/) http://www.domain.com%{REQUEST_URI} [NE,R=301,L]

You can use:

RewriteCond %{HTTP_HOST} ^(www\.)?subdomain\.domain\.com$ [NC]
RewriteRule ^/?$ http://www.domain.com [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