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.

Subscribe
Share

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

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.

I usually overcome this with Nginx to run Port 80 to behave like a Reverse Proxy on top of my Apache Port (set to another port).