简体   繁体   English

仅主子域通过.htaccess重定向到主域

[英]only main Subdomain redirect to main domain through .htaccess

I want to redirect only main subdomain like http://dl.domain.com to domain.com 我只想将主要子域(例如http://dl.domain.com)重定向到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 http://dl.domain.com/123.zip http://dl.domain.com/zippy.zip

How I can do this with .htaccess rules? 如何使用.htaccess规则执行此操作?

I use these .htaccess rules but problem not solve 我使用这些.htaccess规则,但问题无法解决

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]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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