Report this

What is the reason for this report?

setup apache to show www.domain.dk

Posted on July 21, 2017

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!

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.

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>

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.