In the file 000-default.conf (folder site enabled) I have those lines:
# Added to mitigate CVE-2017-8295 vulnerability
UseCanonicalName On
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName test.org
ServerAlias www.test.org
DocumentRoot /var/www/html
<Directory /var/www/html/>
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =www.test.org [OR]
RewriteCond %{SERVER_NAME} =test.org
RewriteRule ^ https://www.%1%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
For example, my website works on this address https://www.test.org/ and in the WordPress general settings I have the same address as the main website address: https://www.test.org/
Checking all redirection scenario, I saw that left small issue - from this URL https://test.org/ don`t work the redirect here: https://www.test.org/
I use this code:
RewriteEngine on RewriteCond %{SERVERNAME} =www.test.org [OR] RewriteCond %{SERVERNAME} =test.org RewriteRule ^ https://www.%1%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
So I checked all redirect scenario:
http://www.test.org/ - redirect here https://www.test.org/
http://test.org/ - redirect here https://www.test.org/
https://test.org/ - dont redirect here https://www.test.org/ https://www.test.org/ - is ok So as you see this URL: https://test.org/ dont redirect here: https://www.test.org/
Also actually I don`t know related it to this code or not, but also I use the special redirection plugin called “Redirection” for WordPress - I set-upped 301 redirects from the / - main page to absolutely another website.
And interesting thing - when I delete this redirect via redirection plugin all seems that works well and all redirection scenario works well, but when I use the redirection plugin only this one scenario:
https://test.org/ - don`t redirect here https://www.test.org/ - it directly begins to redirect to the another my website.
So when i using the redirection plugin from the / main page to another website all those redirects scenario works well except only one:
http://www.test.org/ - redirect here https://www.test.org/ and them to the another website
http://test.org/ - redirect here https://www.test.org/ and them to the another website
https://test.org/ - don`t redirect here https://www.test.org/ but directly redirect to another website
Tell please why it is happening and how to fix this issue?
Many thanks.
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!
Hello,
You need to make sure that you have a VirtualHost for port 443 for your domain name.
The easiest way to do that is to install a Let’s Encrypt SSL certificate with CertBot which would automatically create the Vhost for you.
Hope that this helps! Bobby
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.