您的位置:宽带测速网 > 网站建设 > 怎么通过.htaccess配置二级域名绑定

怎么通过.htaccess配置二级域名绑定

2025-06-11 10:03来源:互联网 [ ]

在Linux主机中使用htaccess文件绑定二级域名的方法

1.首先,在Linux主机新建一个htaccess文件,并打开;

2.htaccess文件打开后,在文件中添加以下配置即可;

例:绑定的二级域名为text.com.cn

# 开启功能

RewriteEngine on

# 绑定的二级域名

RewriteCond %{HTTP_HOST} ^(text.)?com.cn$

RewriteCond %{REQUEST_URI} !^/text/

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ /cms/$1

RewriteCond %{HTTP_HOST} ^(text.)?com.cn$

RewriteRule ^(/)?$ text/index.php [L]

3.最后,htaccess文件配置好后,将文件上传至网站根目录即可;