jen22

Registered
Apr 6, 2018
2
0
1
Arizona
cPanel Access Level
Reseller Owner
Hi,
I'm using WHM and cPanel. My intent is so use sub-domain for each separate cPanel account and then redirect (through .htaccess or other way) to my root-domain/subfolder

example: I've created 2 cpanel accounts under WHM.
1st account: jen.example.com (domain)
2nd account: example.com (domain)

both are hosted on same IP address.

Now I want to upload files to https://jen.example.com but I want that my visitors should see the pages as https://example.com/jen

Example: https://jen.example.com/page1.html should be shown in browser as https://example.com/jen/page1.html

I've tried using .htaccess redirect:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^jen\.example\.com$
RewriteRule ^(.*) https://example.com/jen$1 [R=301,L]

It is redirecting, but litespeed giving a 500 error. Also I use wordpress install on jen.example.com, then it is redirected to example.com/jen but the sub-pages are not redirected.

Is there something setting changes I should do in cPanel account(s)?
Also Is there a need to manually create example.com/jen/ folder?

Please guide me accordingly. my host was not able to help on this! :(
 

cPanelLauren

Product Owner
Staff member
Nov 14, 2017
13,298
1,279
313
Houston
Hi @jen22

Is there a specific reason why you need the two to be separate accounts? I ask this only because it may be easier to achieve what you're looking to do if you created example.com -> then within the cPanel interface create the subdomain jen.example.com.

Once that's done your folders would be created under the /home directory for the example user automatically.

To set up jen.example.com to redirect to example.com/jen you should be able to go to cPanel>>Domains>>Redirects and set up the redirect from the UI

Thank you,
 

jen22

Registered
Apr 6, 2018
2
0
1
Arizona
cPanel Access Level
Reseller Owner
The specific reason is because of inode limit per cpanel account my host has set very low. That's the reason I'm interested to host sub.domain.com(s) and redirect them virtually to domain.com/sub/
 

cPanelLauren

Product Owner
Staff member
Nov 14, 2017
13,298
1,279
313
Houston
Hi @jen22

I understand, what you're describing should work though.

The steps to do this would be similar to what you listed:

1. Create example.com account (pending it didn't already exist)

2. Create a folder in example.com's public_html called jen

3. Create the account jen.example.com

4. Go to cPanel>>Domains>>Redirects and add a redirect for jen.example.com -> http://example.com/jen or https://example.com/jen depending on which you'd rather use

5. Select redirect with or without WWW if you want both to redirect

6. Select Add

Once this is complete the redirection should look like this in the .htaccess file for jen.example.com:

Code:
RewriteCond %{HTTP_HOST} ^jen\.example\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.jen\.example\.com$
RewriteRule ^/?$ "https\:\/\/example\.com\/jen" [R=301,L]
in this example the domain jen.example.com or www.jen.example.com redirects to https://example.com/jen which would hold all the data for the domain.

Thank you,