简体   繁体   中英

AddHandler directly in .htaccess

In this solution , I installed and enabled mod_python .

Why doesn't adding this in .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 . This is a bit a shame, because some people don't have access to modify their <VirtualHost> configuration, and can only modify a .htaccess .

On the other hand, AddHandler php5-script .php seems to be available from .htaccess as detailed here .

As mentioned by @DusanBajic in a comment, adding this solved it:

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

Then simply adding this in the .htaccess file works:

AddHandler mod_python .py
PythonHandler mod_python.publisher

Explanation:

  • 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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