HTACCESS 问题 - 域与子域

发布于 2024-09-26 09:46:02 字数 1314 浏览 2 评论 0原文

我从谷歌和 stackoverflow 得到了很多想法 - 但这些都不是我正在寻找的。这是场景

  1. -

    我从提供商处购买了托管空间。我必须提供一个域名(let abc.com)作为该托管空间的主域。

  2. 然后我发现我必须将该初级域(abc.com)的所有内容直接放入文档根目录中。那不是像 www/abc 或 www/abc.com 这样的目录。

  3. 然后我用谷歌搜索并找到了很多 .htaccess 解决方案。我选择了以下一个 -

    重写引擎开启

    重写基础 /

    RewriteCond %{HTTP_HOST} abc.com

    RewriteCond %{REQUEST_URI} !^/abc.com/(.*) [NC]

    RewriteRule ^(.*)$ /abc.com/$1

  4. 我刚刚将以上行粘贴到现有 .htaccess 文件的末尾(默认)。 一切正常。从那时起,我一直使用 www/abc.com 目录作为我的 abc.com 域。

  5. 最近我向我的 abc.com 域添加了一些子域 (let xyz.abc.com)。但它对我来说表现得很奇怪。所有子域都从 abc.com/subdomain 中查找其内容(例如 abc.com/xyz.abc.com)

  6. 这次我通过 google 没有得到解决方案(我可能错过了)。

请有人帮助我 - 我的情况很糟糕。

编辑: 以下几行从一开始就位于 WebRoot .htaccess 中。之后,我添加了如上所述的附加行(3,4)

# -FrontPage-

IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*

<Limit GET POST>
order deny,allow
deny from all
allow from all
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
AuthName abc.com
AuthUserFile /home/abc/public_html/_vti_pvt/service.pwd
AuthGroupFile /home/abc/public_html/_vti_pvt/service.grp\

再次编辑: 同一托管空间中还有一些其他域(除了主域 abc.com)。这些域有一些工作子域。但主域的子域无法正常工作,正如我上面所解释的。

I have got lots of ideas from google and stackoverflow- but none of those was exactly what i am looking for. here is scenario-

  1. I have bought a hosting space from a provider. I had to provide a domain name(let abc.com) as the primary domain of that hosting space.

  2. Then i have found that i have to put all the contents for that rimary domain(abc.com) into the document root directly. that is no directory like www/abc or www/abc.com.

  3. Then I googled and found lots of .htaccess solution. I picked the following one-

    RewriteEngine On

    RewriteBase /

    RewriteCond %{HTTP_HOST} abc.com

    RewriteCond %{REQUEST_URI} !^/abc.com/(.*) [NC]

    RewriteRule ^(.*)$ /abc.com/$1

  4. I have just paste above lines at the end of the existing .htaccess file (default).
    It was working fine. I have been using www/abc.com directory for my abc.com domain from then.

  5. Recently I have added some subdomains (let xyz.abc.com) to my abc.com domain. But it is behaving strange with me. all subdomains are looking for its contents from abc.com/subdomain (eg. abc.com/xyz.abc.com)

  6. This time i am getting no solution over google (i may missed it).

Someone help me please- i am in bad shape.

EDITED:
Following lines were in WebRoot .htaccess from the beginning. After that I have added additional lines as mentioned above(3,4)

# -FrontPage-

IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*

<Limit GET POST>
order deny,allow
deny from all
allow from all
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
AuthName abc.com
AuthUserFile /home/abc/public_html/_vti_pvt/service.pwd
AuthGroupFile /home/abc/public_html/_vti_pvt/service.grp\

EDITED AGAIN:
There are some other domains(except the main domain abc.com) in the same hosting space. Those domains have some working sub-domains. But sub-domain of main domain is not working as i explained above.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

べ繥欢鉨o。 2024-10-03 09:46:02

更改

RewriteCond %{HTTP_HOST} abc.com

RewriteCond %{HTTP_HOST} ^abc.com$

现在规则不再与您的子域匹配。

更新

# catch www.abc.com and abc.com (and wwwwwwwwwww.abc.com)
RewriteCond %{HTTP_HOST} ^(w+\.)?abc\.com$

Change

RewriteCond %{HTTP_HOST} abc.com

to

RewriteCond %{HTTP_HOST} ^abc.com$

Now the rules do not match your subdomains anymore.

Update

# catch www.abc.com and abc.com (and wwwwwwwwwww.abc.com)
RewriteCond %{HTTP_HOST} ^(w+\.)?abc\.com$
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文