Subdomain to subfolder redirect
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
Example:
I've tried using .htaccess redirect:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^jen\.example\.com$
RewriteRule ^(.*)
-
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, 0 -
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/ 0 -
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 -> 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: 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 to0 -
I wanted to do that myself. However, the system did not work because it did not see an index file after redirection. How can I do it? 0 -
@cimenozlem What is the error you received exactly? 0 -
I'm not getting an error. But since the directory is empty in the main domain, it does not see the contents of the subdomain after redirection. 0 -
Can you show me the redirect you've implemented? 0
Please sign in to leave a comment.
Comments
7 comments