Change Subdomain Into A Subfolder

Have your created a subdomain and want it to become a subfolder? When you want your subdomain to become a subfolder, simply add this line into your .htaccess file.

RewriteEngine On
RewriteCond %{HTTP_HOST} ^subdomain\.maindomain\.com$
RewriteCond %{REQUEST_URI} !^/subdomain/
RewriteRule (.*) /subdomain/$1

Replace subdomain with your subdomain name (plus.google.com where plus is the subdomain name) and main domain with your domain name (google.com). Doing so, your subdomain.maindomain.com will become a maindomain.com/subdomain.

To access your .htaccess file, you need to log in to your cpanel, go to your file manager and tick show hidden files. You can also use an ftp like filezilla to access your .htaccess file. The .htaccess file is usually located in your website root directory. Take note that you should not delete anything in the .htaccess file and also make sure you make a backup of it before making any changes.

To make a backup, rename your current .htaccess file into htaccess.txt and create a new .htaccess file. Copy and paste the content of your backup which is the htaccess.txt to your new .htaccess.

In case you receive an error, restoring your back up will certainly help remove the error you encountered after changing your .htaccess file. Avoid adding blank spaces at the end of the line in your .htaccess. Blank spaces in the end of the line usually causes forbidden error.

Total
0
Shares

Comments are closed.

Related Posts