简体   繁体   中英

Subdomain to folder in Plesk

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

The solution is simple.

You have to create a subdomain of the main domain in Plesk and, in the hosting options, point to the folder as follows:

🏠/httpdocs/folder

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM