.htaccess 该网页有重定向循环?

发布于 2024-12-14 02:29:28 字数 1110 浏览 4 评论 0原文

我想我搞砸了。

我目前正处于学习 Apache .htaccess 的阶段。

我已对我网站上的目录应用了密码保护。 我还有不同的目录,其中包含不同的信息,但这些信息不受保护。

例如:

http://www.example.com/forum/ = 不受保护 http://www.example.com/construction/ = 受保护

现在我知道 .htaccess如果放置在根目录中,文件可以应用于整个网站,或者您可以将 .htaccess 文件应用于特定目录。

的根部

在... http://www.example.com/

我曾经有一个 .htaccess带有 301 重定向的文件(在根文件夹中),该文件将转换 example.com 和/或 http://example.com 进入 http://www.example.com。我完全删除了 301 重定向。

但是,由于某种原因,我仍然收到此错误消息,其中我无法访问... http://www.example.com/forum/ 目录。

我已完成以下所有步骤来解决该问题... 1. 清除缓存/Cookie/会话 - 完全 2. 通过我的操作系统刷新 DNS 3.重新启动我的电脑 4. 拥有 DNS 服务,为我提供最新的 DNS 信息。

我要问的是 A. 如何删除此消息? B. 如何将 example.com 请求转换为 www.example.com 请求而不发生此问题?

谢谢你! 让我知道, 我很感激我将收到的报价, 亚伦

I think I messed up.

I am currently in the stages of learning .htaccess for, of course, Apache.

I have applied a Password Protection to a directory on my website.
I also have different directories that hold different information, that are not protected.

For example:

http://www.example.com/forum/ = Not Protected
http://www.example.com/construction/ = Protected

Now I do know that an .htaccess file can apply to an entire website if placed in the root, or you can have a .htaccess file applied to a specific directory.

In the root of...

http://www.example.com/

I used to have a .htaccess file with a 301 Redirect (In The Root Folder) that would translate all requests of example.com and or http://example.com into http://www.example.com. I removed that 301 Redirect completely.

But, for some reason, I am still getting this error message in which I cannot access the...
http://www.example.com/forum/ directory.

I have completed all of the following steps to troubleshoot the problem...
1. Cleared Cache/Cookies/Sessions - Completely
2. Flushed the DNS via my Operating System
3. Restarted my computer
4. Have a DNS Service in which provides me the latest DNS Information.

What I am asking is A. How do I remove this message? And B. How do I still translate example.com requests into www.example.com requests without having this problem occur?

Thank you!
Let me know,
I appreciate the offer that I will receive,
Aaron

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

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

发布评论

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

评论(1

恰似旧人归 2024-12-21 02:29:28

在您的根文件夹中,您仍然可以放置一个具有以下规则的 .htaccess,以从 example.com 重定向到 www.example.com

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC]
  RewriteRule ^(.*)$ http://www.example.com$1 [R=301,L]
</IfModule>

在受密码保护的文件夹中,放置一个 .htaccess,如下所示:

AuthType Basic
AuthName "Protected folder /construction/"
AuthUserFile /absolute/path/to/your/public/www/folder/construction/.htpasswd
require valid-user

同时放置一个 .htpasswd 在那里。

仅当请求始终与您的重定向条件匹配时,才会发生重定向循环。也许你的根文件夹中有一个错误的 .htaccess 或者还有其他你没有提到的规则?

In your root folder you can still place a .htaccess with the following rule to redirect from example.com to www.example.com

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC]
  RewriteRule ^(.*)$ http://www.example.com$1 [R=301,L]
</IfModule>

In your password protected folder place a .htaccess like this:

AuthType Basic
AuthName "Protected folder /construction/"
AuthUserFile /absolute/path/to/your/public/www/folder/construction/.htpasswd
require valid-user

also place a .htpasswd in there.

A redirect loop only occurs when a requests always matches your redirect condition. Maybe you had a wrong .htaccess in the root folder or there were other rules in there you didn't mention?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文