.htaccess rewrite |
Post Reply |
Author | |
wads24
Newbie Joined: Sep 08 2018 Location: Idaho Status: Offline Points: 2 |
Post Options
Thanks(0)
Posted: Sep 08 2018 at 12:41pm |
So, I found this example where I was able to sucessfully move my main domain from the public_html directory to it's own directory within public_html. Now, I have a few more domains that I use as aliases for the domain, but my host doesn't offer masking in the cPanel. So, I thought that I could use this .httaccess to also accomplish the same thing.
So, I have DomainA.com is the main domain, and all the files for DomainA.com were located in the public_html/ directory. So, with this addition to my .htaccess file in the public_html/ directory I was able to move all my files for public_html/ directory to public_html/DomainA.com directory. ------------------------------------------------------------------ # .htaccess main domain to subdirectory redirect # Do not change this line. RewriteEngine on # Change example.com to be your main domain. RewriteCond %{HTTP_HOST} ^(www.)?DomainA.com$ # Change 'subdirectory' to be the directory you will use for your main domain. RewriteCond %{REQUEST_URI} !^/DomainA.com/ # Don't change the following two lines. RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d # Change 'subdirectory' to be the directory you will use for your main domain. RewriteRule ^(.*)$ /DomainA.com/$1 # Change example.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} ^(www.)?DomainA.com$ RewriteRule ^(/)?$ DomainA.com/index.html [L] ------------------------------------------------------------------ So, I have DomainB.com Directory/ DomainC.com Directory/ DomainD.com Directory/ DomainE.com Directory located in the public_html/ directory that I would also like to use the files from public_html/DomainA.com/ but when I edit the .htaccess file to B,C,D, or E Domains I get a Forbidden error. EXAMPLE: DomainB.com # .htaccess main domain to subdirectory redirect # Do not change this line. RewriteEngine on # Change example.com to be your main domain. RewriteCond %{HTTP_HOST} ^(www.)?DomainB.com$ # Change 'subdirectory' to be the directory you will use for your main domain. RewriteCond %{REQUEST_URI} !^/DomainA.com/ # Don't change the following two lines. RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d # Change 'subdirectory' to be the directory you will use for your main domain. RewriteRule ^(.*)$ /DomainA.com/$1 # Change example.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} ^(www.)?DomainB.com$ RewriteRule ^(/)?$ DomainA.com/index.html [L] Thank you in advance for any reply to assist me with this problem. |
|
nancywilson
Newbie Joined: Oct 15 2018 Status: Offline Points: 1 |
Post Options
Thanks(0)
|
The .htaccess files are used to rewrite the rules to make the URLs so clean. these are the main part of websites. I am getting the issue to enable the .htaccess file. I also enable but not working. I install Avast antivirus and also try on avast customer service for the help purpose but did not get any response.
|
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |