Knowledgebase

Wildcard SSL Certificiates

Accessing the .htaccess file

The .htaccess file is located in the public_html folder. While you can use an FTP or SSH client to access the file, for this article we will be using the File Manger.
  1. Login to your cPanel.
  2. Click the "File Manager", located in the Files section of the cPanel.
  3. File Manager
  4. Choose to open the "Web Root (public_html/www)" Web Root
    Note: Be sure to check the box "Show Hidden Files (dotfiles)."
  5. Show Hidden Files
  6. Right click the .htaccess file and choose "Edit" or "Code Edit
You will need to copy the following text into your .htaccess file. Please pay close attention to the comments (lines starting with #) so that you can properly setup the rewrite for your subdomains.
Note:You will need to replace subdomain with your subdomain and yourmaindomain.com with your domain name.

 

# most-host.com
# .htaccess main domain to subdirectory 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} ^(subdomain.)?yourmaindomain.com$
# Change 'subdirectory' to be the directory you will use for your main domain.
RewriteCond %{REQUEST_URI} !^/subdirectory/
# Don't change this line.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Change 'subdirectory' to be the directory you will use for your main domain.
RewriteRule ^(.*)$ /subdirectory/$1
# Change yourdomain.com to be your main domain again.
# Change 'subdirectory' to be the directory you will use for your main domain
# followed by / then the main file for your site, index.php, index.html, etc.
RewriteCond %{HTTP_HOST} ^(subdomain.)?yourmaindomain.com$
RewriteRule ^(/)?$ subdirectory/index.php [L]

 

Once you have modified this code you may need to clear your browser cache to be able to see the redirect.


Was this answer helpful?

Add to Favourites Add to Favourites

Print this Article Print this Article

Also Read
Hotlink Protection (Views: 1231)
Force SSL on all pages. (Views: 3617)
.htaccess (Views: 6987606)

Client Login

Email

Password

Remember Me