Question
How Correctly Set-Up The 301 Redirect Only for Main Website Page
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
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.
×