Hi, I have a domain dagenssalg.dk and both www.dagenssalg.dk and dagenssalg.dk is sendt to the root of my apache server.
But, www.dagenssalg.dk only sends me to “index of /” where dagenssalg.dk runs the python script there as it’s supposed to.
Here is my sites-avaliable/FlaskApp.conf:
ServerName dagenssalg.dk
ServerAlias www.dagenssalg.dk
ServerAdmin krestensb@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
RewriteEngine on
RewriteCond %{SERVER_NAME} =dagenssalg.dk [OR]
RewriteCond %{SERVER_NAME} =www.dagenssalg.dk
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>```
Any help is very much appreciated.
Best regards
Kresten
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!
Hi @krestensb
The configuration that you’ve pasted is for your HTTP (port 80) site and you can change that to the following:
<VirtualHost *:80>
ServerName dagenssalg.dk
ServerAlias www.dagenssalg.dk
Redirect permanent / https://www.dagenssalg.dk/
</VirtualHost>
And then you need to paste your <VirtualHost *:443> block, since that’s the configuration which handles your HTTPS (port 443) site.
Hi, Thanks for answering!
Now I changed it to whats below.
I don’t thin I understood you right Now www.dagenssalg.dk is returning: ERR_TOO_MANY_REDIRECTS
dagenssalg.dk is showing as usual.
ServerAdmin krestensb@gmail.com
ServerName dagenssalg.dk
ServerAlias www.dagenssalg.dk
Redirect permanent / https://www.dagenssalg.dk/
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
RewriteEngine on
RewriteCond %{SERVER_NAME} =dagenssalg.dk [OR]
RewriteCond %{SERVER_NAME} =www.dagenssalg.dk
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>```
I never added any .conf for port 443 before I started to implement your code.
Would I need one .conf with two bloks like this?
<VirtualHost *:80>
ServerName dagenssalg.dk
ServerAlias www.dagenssalg.dk
Redirect permanent / https://www.dagenssalg.dk/
</VirtualHost>
<VirtualHost *:443>
ServerName dagenssalg.dk
ServerAlias www.dagenssalg.dk
Redirect permanent / https://www.dagenssalg.dk/
</VirtualHost>
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.