Report this

What is the reason for this report?

How Correctly Set-Up The 301 Redirect Only for Main Website Page

Posted on July 7, 2019

Hi everyone,

I need help with not easy redirect situation regarding my two websites:

So currently I have one website that works for example on this address:

https://www.test.org/ - on the general WordPress website setting I have the same address: https://www.test.org/

Also in this file 000-default.conf (folder site enabled) on FTP 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>

the main question is how I can set-up 301 redirects only from this http://www.test.org/ main page to another website main page?

means that all rest scenario like those:

from https://test.org/ to https://www.test.org/ from http://test.org/ to https://www.test.org/

should continue working as it was in this code:

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]

Many thanks

The developer cloud

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

Start building today

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.