• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Issue Redirection Issue Wordpress Subdirectory Install

sall10

Basic Pleskian
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:

OSCentOS Linux 7.8.2003 (Core)
ProductPlesk 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
 
The hint is that you have set your home directory as usual (/var/www/vhosts/domain.com/httpdocs ) but then you installed your Wordpress in subdirectory :)

there's no need for messing with Apache directives or .htaccess for that matter. Just revert to default and install everything normally. Or point your home where it need to.
 
As the site is already indexed revert to default and install everything normal is not an option :) What you mean with Point your Home to ??

I would like to set this with Apache and nginx to have the correct redirects to my Subdirectory Install
 
Last edited:
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:

OSCentOS Linux 7.8.2003 (Core)
ProductPlesk 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
He confuses me with his statement too but I think he is trying to say that you have installed WordPress on some other page instead of installing it on your main page. Your site domain is all that you should apply to.
 
Back
Top