问题描述
限时送ChatGPT账号..我最近注册了一个域名 kbcsurveyors.然后,我创建了两个子域,它们在根文件夹中创建了两个新文件夹.
I recently registered a domain name kbcsurveyors. Then, I created two sub-domains, which created two new folders in the root folder.
我的动机是,如果我输入 kbcsurveyors/preinspection,它应该指向 preinspection.kbcsurveyors强>.其他子域也一样.
My motive is that if I type kbcsurveyors/preinspection, it should point to preinspection.kbcsurveyors. Same for other sub domains.
在我放置在 mydomainname 根目录中的 .htaccess 中,我写了以下几行:
In my .htaccess, which I placed inside root of mydomainname, I have written following lines:
RewriteEngine On
RewriteBase /
RewriteRule ^preinspection/(.*)$ https://kbcsurveyors/$1 [L,NC,QSA] # Handle requests for "Preinspection"
但是这个文件结构不起作用.
But this file structure does not work.
如何编写 .htaccess 文件来实现我想要的?
How do I write the .htaccess file to achieve what I want?
问候
推荐答案
删除或注释掉您现有的规则.
Remove or comment out your existing rule.
使用此规则创建一个新文件 preinspection/.htaccess
:
Create a new file preinspection/.htaccess
with this rule:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^preinspection\.kbcsurveyors\$ [NC]
RewriteEngine .* http://preinspection.kbcsurveyors/$0 [L,NE,R=301]
这篇关于如何重写子域的规则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
更多推荐
[db:关键词]
发布评论