1

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.

Basj
  • 41,386
  • 99
  • 383
  • 673
  • 1
    Do you have `AllowOverride` set to `All` (or at least `FileInfo`) in your virtual host (or global) configuration? – Dusan Bajic Nov 27 '19 at 12:24
  • @DusanBajic Indeed, adding `AllowOverride All` solved it, as well as `Allow from all`. – Basj Nov 27 '19 at 20:24

1 Answers1

1

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.

Basj
  • 41,386
  • 99
  • 383
  • 673