静态站点 apache 和动态/成员站点 django

发布于 2024-08-14 09:10:39 字数 611 浏览 2 评论 0原文

我有一个静态内容网站,所有运行在 apache 上的网站都可以访问。作为其附属,有一个在 django 上运行的会员站点。我在“共享”我的 .css 并使双方在外观上相同方面没有遇到任何问题,但我似乎不太明白的是让我的 django 站点受到 django 密码保护(附加警告,所有成员材料,从登录开始,经过 443)。

我可以为所有页​​面提供服务,我尝试使用 mod_rewrite 如下:

<Directory /Library/Webserver/Documents>
.
.
.
</Directory>

WSGIScriptAlias /members /usr/local/django/mysite/apache/django.wsgi 


<Directory /members>
    RewriteCond %{HTTPS} off
    RewriteRule (.*) https://{HTTP_HOST}%{REQUEST_URI} [L]
.
.
</Directory>

我已经尝试了上面 '/members 位置中一千个不同项目中的每一个,似乎没有任何内容(是的,包括 RewriteEngine On - 我可以观看调试出来了)。

I have a site for static content, accessible to all that runs on apache. As an adjunct to that, there is a members site that runs on django. I haven't had any issue 'sharing' my .css and making both sides equivalent in appearance, but what I can't quite seem to grok is getting my django site to be django password protected (with the additional caveat that all member material, from the login forward, goes through 443).

I can serve all the pages, I have tried to use mod_rewrite as follows:

<Directory /Library/Webserver/Documents>
.
.
.
</Directory>

WSGIScriptAlias /members /usr/local/django/mysite/apache/django.wsgi 


<Directory /members>
    RewriteCond %{HTTPS} off
    RewriteRule (.*) https://{HTTP_HOST}%{REQUEST_URI} [L]
.
.
</Directory>

I have tried every one of a thousand different items in the '/members location above, nothing seems to hit (and yes, RewriteEngine On is included - I can watch the debug come out).

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

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

发布评论

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

评论(1

拥醉 2024-08-21 09:10:39

尝试:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

您应该重定向回请求所针对的同一主机,而不一定是实际的 Web 服务器主机。

我也不相信 mod_rewrite 中有 %{URI} 变量。应该使用%{REQUEST_URI}。


编辑 1

根据注释,应该是:

<Location /members>
    RewriteCond %{HTTPS} off
    RewriteRule (.*) https://{HTTP_HOST}%{REQUEST_URI} [L]
.
.
</Location>

或:

<Directory /usr/local/django/mysite/apache>
    RewriteCond %{HTTPS} off
    RewriteRule (.*) https://{HTTP_HOST}%{REQUEST_URI} [L]
.
.
</Directory>

因此,位置用于 URL,目录用于文件系统目录。

Try:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

You should be redirecting back to same host the request was made against, not necessarily the actual web server host.

I also don't believe there is a %{URI} variable in mod_rewrite. Supposed to use %{REQUEST_URI}.


EDIT 1

As per comments, should be:

<Location /members>
    RewriteCond %{HTTPS} off
    RewriteRule (.*) https://{HTTP_HOST}%{REQUEST_URI} [L]
.
.
</Location>

or:

<Directory /usr/local/django/mysite/apache>
    RewriteCond %{HTTPS} off
    RewriteRule (.*) https://{HTTP_HOST}%{REQUEST_URI} [L]
.
.
</Directory>

So, Location is for URL and Directory is for file system directory.

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