如何重写子域的规则

编程入门 行业动态 更新时间:2024-10-11 05:22:11
本文介绍了如何重写子域的规则的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送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:关键词]

本文发布于:2023-04-28 13:10:17,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:重写   规则

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!