Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8931325
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T09:05:32+00:00 2026-06-15T09:05:32+00:00

This is a very specific question, but a good answer might also give me

  • 0

This is a very specific question, but a good answer might also give me better understanding of Apache request processing.

I have a python script to generate a HTML page. The script is called by means of the following apache config item:

 WSGIScriptAliasMatch ^.*\.mako$ /usr/local/lib/cgi-bin/myscript.py

But I would rather use .mako files just the way .php files are commonly used. That, is for a request matching ^.*\.mako$, the script should only be called when there is a file on the server which would be served by apache itself if the config item was not there.
And I would also access that file in the python script.

Is that at all possible? I don’t want to use ugly hacks trying to deduce a filename in the python script from the Request URI (which indeed is handled over wsgi).

UPDATE:

Thanks for the very nice solution! I thought I’d publish my final setup because it seems many have search for something similarly flexible. What I want is a very mixed environment, that is, I want to have static and dynamic content in the same directories to ease editing. Also, we must be able to access dynamic content as a fallback transparently. E.g. Request for http://someserver/file.html, but there is no physical /var/www/file.html file, then produce it dynamically using the existing /var/www/file.html.mako.

apache.conf:

# Disable MultiViews, it will get in your way!

# if resource.html doesn't exist, but resource.html.mako does,
# then use that
RewriteCond ${REQUEST_FILENAME} !-f
RewriteCond ${REQUEST_FILENAME}.mako -f
RewriteRule (.*\.html) $1.mako

# Make .mako files dynamically interpreted by /usr/.../mako-handler.py
AddHandler x-application/mako-template .mako
Action     x-application/mako-template /mako-handler
WSGIScriptAlias /mako-handler /usr/.../mako-handler.py

mako-handler.py:

...
physical_template_filepath = environ['PATH_TRANSLATED']
...
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T09:05:34+00:00Added an answer on June 15, 2026 at 9:05 am

    Try using:

    AddHandler x-application/mako-template .mako
    Action x-application/mako-template /mako-handler
    WSGIScriptAlias /mako-handler /usr/local/lib/cgi-bin/myscript.py
    

    The sequence is that .mako extension will be mapped to mime type of ‘x-application/mako-template’. That mime type is then mapped to URL ‘/mako-handler’ and that URL is then mapped to the WSGI script.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This question might appear very simple, but i haven't found an answer yet, so
this is a very specific question, but i also have very specific details on
This is a very narrow and specific question, but I know there are someone
I asked this question yesterday got a pretty good answer but can't figure out
I realize that this might be a duplicate question but this question is very
First of I'm very sorry but this questions is not so so specific. All
This is a very specific question which will probably earn me the tumbleweed badge,
This is a very specific question for a Google Chrome extension. http://www.meebo.com/mobile/ This page
I'm sure this question has been answered before, but I can't find an answer
Though the question is very specific, I'd also really appreciate general advice and other

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.