• We value your experience with Plesk during 2024
    Plesk strives to perform even better in 2025. To help us improve further, please answer a few questions about your experience with Plesk Obsidian 2024.
    Please take this short survey:

    https://pt-research.typeform.com/to/AmZvSXkx

  • We are developing a new feature in Plesk that will help you promote your websites or business on social media. We want to conduct a one-hour online UX test to present the prototype and collect feedback. If you are interested in the feature, please book a meeting via this link.
    Thank you in advance!
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.

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