NOTE: This question is different from ' Add a prefix to all Flask routes ' as I am trying to resolve this at apache level. Additional, the suggested fix for flask routes did not work!
Following on from this post , I'm trying to set up apache to serve PHP files by default, but point a given alias (ie /flaskapp
) to a wsgi path. The wsgi file in turn routes requests to a python flask app.
Here's the apache config that I'm trying (under 000-default.conf
):
<VirtualHost *:80>
ServerName localhost
ServerAdmin webmaster@localhost
Alias / /var/www/html/
<Directory "/var/www/html">
Order Deny,Allow
Allow from all
Require all granted
</Directory>
WSGIScriptAlias /flaskapp "/var/www/flaskapp/deploy.wsgi"
<Directory /var/www/flaskapp>
Options +ExecCGI
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
After doing a service apache2 restart
I find that requests to http://myip/flaskapp
result in a 404 error. Everything else works fine.
Things I've tried so far:
app.config['APPLICATION_ROOT'] = '/flaskapp'
to my app.py file, as suggested the question ' Add a prefix to all Flask routes ' (Didn't have any effect) Where could I be going wrong?
Instead of:
Alias / /var/www/html/
<Directory "/var/www/html">
Order Deny,Allow
Allow from all
Require all granted
</Directory>
use:
DocumentRoot /var/www/html/
<Directory "/var/www/html">
Order Deny,Allow
Allow from all
Require all granted
</Directory>
Using '/' with Alias
takes precedence over everything else including mod_wsgi's ability to intercept requests at a sub URL. So for stuff at root of the site you need to use DocumentRoot
directive.
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.