M
M
Michael2017-03-28 22:50:31
Apache HTTP Server
Michael, 2017-03-28 22:50:31

How to change virtualhosts so that there is no redirect from the main one?

When accessing the site, redirects for https and www are configured. The site only works with https://www or a redirect.
I'm not a configuration wizard and I guess that you can configure it more competently, but the option works fine.

<VirtualHost *:80>
    ServerName domain.com
    ServerAlias www.domain.com
    Redirect permanent / https://www.domain.com/
</VirtualHost>
<VirtualHost *:443>
    ServerName domain.com
    Redirect permanent / https://www.domain.com/
</VirtualHost>
<VirtualHost *:443>
    ServerName www.domain.com
    DocumentRoot /var/www/domain.com/site
</VirtualHost>

We set the task to make a redirect exception for https for the main page. Those. now the main page should work like this:
domain.com => www.domain.com permanent
www.domain.com
https://domain.com => https://www.domain.com permanent
All other pages as before:
domain.com /page => https://www.domain.com/page permanent
www.domain.com/page => https://www.domain.com/page
https://domain.com/page => https:/ /www.domain.com/page permanent
How to make an exception for the main page or how to rewrite the rules?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question