I would like to host several websites, each one being in their own subfolder. I would be using cpanel on a shared hosting plan.
The websites would reside in their own folders on the server: Public_html/website_1, Public_html/website_2, Public_html/website_3,
Each website would have their own domain name (not a sub domain). https://website_1.com, https://website_2.com, https://website_3.com,
What is the best way to achieve this setup and not showing the subfolder in the URL? I would like to not have the URL show up as: https://website_1.com/website_1/ but to show up as https://website_1.com/
Thanks!
This is a pre-setup question.
CodePudding user response:
Despite being possible, I do not recommend it. If all the sites were in the same folder, if one of them were invaded, all the sites in the same folder will.
Register all the domains in the account DNS
Inside the .htaccess in the "root" folder
Options FollowSymLinks -MultiViews RewriteEngine On RewriteBase /
RewriteCond %{HTTP_HOST} ^(www.)?example1.com$ [NC] RewriteRule ^ http://www.example1.com/site1/%{REQUEST_URI} [L,NE,P]
RewriteCond %{HTTP_HOST} ^(www.)?example2.com$ [NC] RewriteRule ^ http://www.example1.com/site2/%{REQUEST_URI} [L,NE,P]
CodePudding user response:
It isn't recommended to do that as it can complicate debugging and you may most likely have some request clashes as they are in the same source directory.
However, to achieve that, you can:
- Go to cpanel
- Under Domain Name, select Zone Editor
- Add a new Record
- Add a new CNAME record and remap the domain to point to where the files are in the public_html directory.
But ensure that your domain names are from within the same DNS.