By devex
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.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
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).
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.