简体   繁体   English

AddHandler 直接在 .htaccess 中

[英]AddHandler directly in .htaccess

In this solution , I installed and enabled mod_python .这个解决方案中,我安装并启用了mod_python

Why doesn't adding this in .htaccess为什么不在.htaccess添加这个

AddHandler mod_python .py
PythonHandler mod_python.publisher

work?工作?

It works if I add this in a <VirtualHost> configuration, but it doesn't seem to work from a .htaccess .如果我在<VirtualHost>配置中添加它,它会起作用,但它似乎不适用于.htaccess This is a bit a shame, because some people don't have access to modify their <VirtualHost> configuration, and can only modify a .htaccess .这有点可惜,因为有些人无权修改他们的<VirtualHost>配置,只能修改.htaccess

On the other hand, AddHandler php5-script .php seems to be available from .htaccess as detailed here .另一方面, AddHandler php5-script .php似乎可以从.htaccess详见此处

As mentioned by @DusanBajic in a comment, adding this solved it:正如@DusanBajic 在评论中提到的,添加这个解决了它:

<VirtualHost *:80>
  ...
  <Directory />
    AllowOverride All
    Allow from all
  </Directory>
</VirtualHost>

Then simply adding this in the .htaccess file works:然后只需将其添加到.htaccess文件中即可:

AddHandler mod_python .py
PythonHandler mod_python.publisher

Explanation:解释:

  • AllowOverride All : AllowOverride All

    When the server finds an .htaccess file (as specified by AccessFileName), it needs to know which directives declared in that file can override earlier configuration directives.当服务器找到 .htaccess 文件(由 AccessFileName 指定)时,它需要知道在该文件中声明的哪些指令可以覆盖早期的配置指令。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM