> On 13 Jan 2016, at 4:14 AM, Gavin Cannizzaro <[email protected]> 
> wrote:
> 
> Hi all,
> 
> I love mod_wsgi-express.  As someone relatively new to Linux, Apache, Python, 
> and WSGI, "express" works as advertised by getting me up and running.  I'm 
> already using it in production.
> 
> When I use a rewrite rule in the custom configuration, though, it is 
> completely ignored.
> 
> My test case is just a few lines, calling mod_wsgi-express with a standard 
> test script, a port number, a document-root, and an included config.
> 
> The included config has just
> 
> RewriteEngine On
> RewriteRule ^ /blah [R=301]
> 
> (I don't actually want redirects, but it's a stronger test.)
> 
> In any case, I don't see the rule being picked up.  I know that I have 
> mod_rewrite enabled, and it works in a regular Apache site.  And even with 
> express, I'm sure that the module is loaded, based on an IfModule rule that 
> sets a header.
> 
> Is this supposed to be supported with express?  Does it need to be used in 
> conjunction with some other configuration?  I've seen Graham suggest rewrite 
> rules in reference to various issues, but not specifically where "express" is 
> involved.

Unfortunately it isn’t that simple. Because mod_wsgi-express uses rewrite rules 
to allow the WSGI application to overlay a static document root, adding rewrite 
rules at the end of the configuration file at top level will not be recognised, 
or if put inside of a Location directive will usually screw things up. Any 
rewrite rules likely need to be supplied separately with an option used to 
point at the rewrite file. The rules would then need to be included in a 
particular location within the generated configuration just after the rewrite 
rules mod_wsgi uses. Even then there may be complications or rules would need 
to be written a certain way.

The alternative for simple redirect rules is to use the redirect directives 
from mod_alias.

    https://httpd.apache.org/docs/2.4/mod/mod_alias.html 
<https://httpd.apache.org/docs/2.4/mod/mod_alias.html>

You can thus quite happily use something like:

    Redirect /dog /cat
    RedirectMatch ^/?$ /index

For more complicated rewrite rules, would need to see what exactly you are 
trying to do.

I will though have a quick try at adding a —rewrite-rules option and include it 
at where I think they need to be and see what is possible.

BTW, if using Apache 2.4, it is very easy to enable rewrite trace logs by doing:

    mod_wsgi-express start-server tests/environ.wsgi --include-file 
redirect.conf --log-level 'info rewrite:trace8' --log-to-terminal

That is, use —log-level with quoted option ‘info rewrite:trace8’.

That way you can see whether rewrite rules are applied at all, what they are 
being given and what it generates.

Graham

-- 
You received this message because you are subscribed to the Google Groups 
"modwsgi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/modwsgi.
For more options, visit https://groups.google.com/d/optout.

Reply via email to