Home > Software engineering >  Subdomain to folder in Plesk
Subdomain to folder in Plesk

Time:01-14

I use Plesk and I need to display the content of a folder in a subdomain.

I have the .htaccess file as follows:

RewriteEngine On

#Redirect HTTP and WWW to HTTPS without WWW
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteCond %{HTTP_HOST} ^(?:www\.)?(. )$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [L,NE,R=301]

#Redirect subdomain to folder
RewriteCond %{HTTP_HOST} ^sub.domain.com
RewriteRule ^(.*)$ /sub/$1 [L,NC,QSA]

The first rules work correctly redirecting to the secure version with www. But the following rules don't work.

In the DNS records, I have created a CNAME record from sub.domain.com to domain.com, is this correct?

When accessing sub.domain.com from the browser, it redirects me to the Plesk login page (sub.domain.com/login_up.php), and any other files (existing in the folder) give a 404 error.

Thanks in advance for the help, I'm a web developer but I don't understand servers

  • Related