Question
FlaskApp won't apply mod rewrite from htaccess
Hi there, does anyone knows if there is anything -special- that has to be done for my FlaskApp to apply the url-rewrite pattern from htaccess? I have a fully functional FlaskApp with mod rewrite enabled, and a correct RegEx rule (tested, works) but it simply won’t be applied to the URLs.
This is my htaccess:
RewriteEngine On
RewriteRule ^average_temperatures/([^/.]+)/([^/.]+)/([^/.]+)/?$ average_temperatures?city1=$1&city2=$2&city3=$3
FlaskApp.conf:
<VirtualHost *:80>
ServerName weather-averages.co.uk
ServerAdmin petrol.bears@gmail.com
WSGIScriptAlias / /var/www/FlaskApp/flaskapp.wsgi
<Directory /var/www/FlaskApp/FlaskApp/>
Order allow,deny
Allow from all
</Directory>
Alias /static /var/www/FlaskApp/FlaskApp/static
<Directory /var/www/FlaskApp/FlaskApp/static/>
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<VirtualHost *:80>
ServerName www.weather-averages.co.uk
Redirect permanent / http://weather-averages.co.uk/
</VirtualHost>
and 000-default.conf
VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
I enabled the log for this rule, and I see that the rule is applied, but to all other things, but the URL I want:
[perdir /var/www/] applying pattern '^average_temperatures/([^/.]+)/([^/.]+)/([^/.]+)/?$' to uri 'index.pl'
[perdir /var/www/] applying pattern '^average_temperatures/([^/.]+)/([^/.]+)/([^/.]+)/?$' to uri 'index.cgi'
[perdir /var/www/] applying pattern '^average_temperatures/([^/.]+)/([^/.]+)/([^/.]+)/?$' to uri ''
And so on…
Any help is greatly appreciated.
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
×