Hello,
I have my website installed in a subdirectory under /blog. I have the issue that When I test my Pages or Post, with http://domain.com/example-page/ and http://www.domain.com/example-page/ I get Status Code 200 (instead 301) and not redirected to Version https://domain.com/example-page/ or https://domain.com/example-post/
I tested also the redirects for Domain URL domain.com with http://, https://, http://www., https://www, here I get redirected to Website Domains Names & Hosting | Domain.com what is correct.
My Actual Config:
Plesk Hosting Settings:
Document root: httpdocs
Preferred Domain: domain.com
SSL/TLS Support marked
WordPress Address (URL) Domain.com | Blog
Site Address (URL). https://domain.com
Document Root:
/var/www/vhosts/domain.com/httpdocs
htaccess Code:
# BEGIN WordPress
# The directives (lines) between `BEGIN WordPress` and `END WordPress` are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Index.php Wordpress
/** Loads the WordPress Environment and Template */
require( dirname( __FILE__ ) . '/blog/wp-blog-header.php' );
Subdirectory:
/var/www/vhosts/domain.com/httpdocs/blog
htaccess Code:
# Rewrite|Redirect http to https|SSL & www to non-www
RewriteEngine On
RewriteBase /blog/
RewriteCond %{HTTPS} !=on
RewriteCond %{SERVER_PORT} ^80
RewriteRule (.*) https://domain.com%{REQUEST_URI} [R=301,L]
RewriteRule ^index\.php$ - [L]
I saw also here in the Support Article How to enable redirection from HTTP to HTTPS for a domain in Plesk , the solution with Enabling HTTPS redirection using additional Apache and nginx directives in Plesk (Any Plesk version on Linux)
Apache Directives:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}$1 [R,QSA]
</IfModule>
Copy the following directives to the Additional nginx directives
if ($ssl_protocol = "") {
rewrite ^/(.*) https://$server_name/$1 permanent;
}
When I would use Apache and Nginx Directives for the Redirection, how do I have to adapt the Document Root htaccess and the Subdirectory to get it work? Would this also fix my issue?
Thx
I have my website installed in a subdirectory under /blog. I have the issue that When I test my Pages or Post, with http://domain.com/example-page/ and http://www.domain.com/example-page/ I get Status Code 200 (instead 301) and not redirected to Version https://domain.com/example-page/ or https://domain.com/example-post/
I tested also the redirects for Domain URL domain.com with http://, https://, http://www., https://www, here I get redirected to Website Domains Names & Hosting | Domain.com what is correct.
My Actual Config:
OS | CentOS Linux 7.8.2003 (Core) |
Product | Plesk Obsidian Version 18.0.26, last updated on April 20, 2020 06:00 PM |
Plesk Hosting Settings:
Document root: httpdocs
Preferred Domain: domain.com
SSL/TLS Support marked
WordPress Address (URL) Domain.com | Blog
Site Address (URL). https://domain.com
Document Root:
/var/www/vhosts/domain.com/httpdocs
htaccess Code:
# BEGIN WordPress
# The directives (lines) between `BEGIN WordPress` and `END WordPress` are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Index.php Wordpress
/** Loads the WordPress Environment and Template */
require( dirname( __FILE__ ) . '/blog/wp-blog-header.php' );
Subdirectory:
/var/www/vhosts/domain.com/httpdocs/blog
htaccess Code:
# Rewrite|Redirect http to https|SSL & www to non-www
RewriteEngine On
RewriteBase /blog/
RewriteCond %{HTTPS} !=on
RewriteCond %{SERVER_PORT} ^80
RewriteRule (.*) https://domain.com%{REQUEST_URI} [R=301,L]
RewriteRule ^index\.php$ - [L]
I saw also here in the Support Article How to enable redirection from HTTP to HTTPS for a domain in Plesk , the solution with Enabling HTTPS redirection using additional Apache and nginx directives in Plesk (Any Plesk version on Linux)
Apache Directives:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}$1 [R,QSA]
</IfModule>
Copy the following directives to the Additional nginx directives
if ($ssl_protocol = "") {
rewrite ^/(.*) https://$server_name/$1 permanent;
}
When I would use Apache and Nginx Directives for the Redirection, how do I have to adapt the Document Root htaccess and the Subdirectory to get it work? Would this also fix my issue?
Thx