使用 Django 在 Apache 中拒绝访问

发布于 2024-11-18 08:22:00 字数 832 浏览 8 评论 0原文

我正在尝试设置一个像 AlwaysData 上解释的 Django 项目,但在我自己的计算机上。

我正在使用 ArchLinux。

当我转到包含 FastCGI 脚本的目录(与上面的链接中相同的 django.fcgi)时,我的 error_log 中的访问被拒绝:

client denied by server configuration: /var/www/home

但是,如果我转到 directory/django.fcgi,我可以访问该项目 而不仅仅是 directory/

我的 .htaccess 是:

AddHandler fastcgi-script .fcgi
Options +ExecCGI
DirectoryIndex django.fcgi
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ django.fcgi/$1 [QSA,L]

如果我注释最后一行,我不会收到拒绝访问错误,并且我可以通过两种方法访问我的 django 项目(directory/directory/django.fcgi< /代码>)。

尽管如此,我需要这个 .htaccess 的最后一行来获取干净的 URL。

你知道我的配置有什么问题吗?

I am trying to setup a Django project like explained on AlwaysData, but on my own computer.

I'm using ArchLinux.

I got an access denied in my error_log when I went to the directory containing the FastCGI script (the same django.fcgi as in the link above) :

client denied by server configuration: /var/www/home

However, I can access the project if I go to directory/django.fcgi instead of only directory/.

My .htaccess is :

AddHandler fastcgi-script .fcgi
Options +ExecCGI
DirectoryIndex django.fcgi
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ django.fcgi/$1 [QSA,L]

If I comment the last line, I does not get the acces denied error and I can access my django project by both methods (directory/ and directory/django.fcgi).

Nevertheless, I need the last line of this .htaccess to get clean URLs.

Do you know what is the problem in my configuration?

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

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

发布评论

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

评论(1

近箐 2024-11-25 08:22:00

我最终使用 mod_wsgi 解决了我的问题。

I finally used mod_wsgi to solve my problem.

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