How to Point my Primary Domain to Sub Folder

  • Post category:Blog
  • Post comments:0 Comments

In cPanel, pointing your primary domain to a subfolder is usually achieved through the “Addon Domains” feature. Here’s a step-by-step guide:

  1. Log in to cPanel:Access your cPanel account using your credentials.
  2. Navigate to “Addon Domains”:Look for the “Domains” section in cPanel and click on the “Addon Domains” icon.
  3. Add an Addon Domain:
    • In the “Create an Addon Domain” section, enter the details for your primary domain.
    • The “New Domain Name” field should be your primary domain (e.g., yourdomain.com).
    • The “Subdomain/FTP Username” field will be automatically filled based on your domain.
    • In the “Document Root” field, specify the subfolder path relative to your account’s home directory where you want your primary domain to point to. For example, if you want to point to a subfolder named “subfolder”, you should enter something like /public_html/subfolder.
  4. Click “Add Domain”:Once you’ve entered the details, click the “Add Domain” button.
  5. Update your Website:Your primary domain is now pointed to the specified subfolder. Upload or move the content you want to be displayed for your primary domain to the subfolder you specified earlier.
  6. Testing:To verify that your primary domain is correctly pointing to the subfolder, simply access your primary domain in a web browser. It should display the content from the subfolder.

Remember, cPanel interfaces can slightly differ based on hosting providers and versions, so the steps might vary slightly. If you’re unsure or facing any issues, it’s recommended to consult your hosting provider’s documentation or contact their support for assistance.

== Second Method ===

=== Script Copy Start Here ===

# .htaccess main domain to subfolder redirect
# Copy and paste the following code into the .htaccess file
# in the public_html folder of your hosting account
# make the changes to the file according to the instructions.

# Do not change this line.
RewriteEngine on

# Change yourdomain.com to be your main domain.
RewriteCond %{HTTP_HOST} ^(www.)?yourmaindomain.com$

# Change ‘subfolder’ to be the folder you will use for your main domain.
RewriteCond %{REQUEST_URI} !^/subfolder/

# Don’t change this line.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# Change ‘subfolder’ to be the folder you will use for your main domain.
RewriteRule ^(.*)$ /subfolder/$1

# Change yourdomain.com to be your main domain again.
# Change ‘subfolder’ to be the folder you will use for your main domain
# followed by / then the main file for your site, index.php, index.html, etc.

RewriteCond %{HTTP_HOST} ^(www.)?yourmaindomain.com$
RewriteRule ^(/)?$ subfolder/index.php [L]

=== Script End ===

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments