BullGuard Antivirus Sale - 60% Off with openElement !
Forum Home Forum Home >

openElement

> openElement General Discussion
  New Posts New Posts RSS Feed - .htaccess rewrite
  FAQ FAQ  Forum Search   Register Register  Login Login

.htaccess rewrite

 Post Reply Post Reply
Author
Message
wads24 View Drop Down
Newbie
Newbie


Joined: Sep 08 2018
Location: Idaho
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote wads24 Quote  Post ReplyReply Direct Link To This Post Topic: .htaccess rewrite
    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.   
Back to Top
nancywilson View Drop Down
Newbie
Newbie


Joined: Oct 15 2018
Status: Offline
Points: 1
Post Options Post Options   Thanks (0) Thanks(0)   Quote nancywilson Quote  Post ReplyReply Direct Link To This Post Posted: Oct 15 2018 at 11:58am
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.
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.047 seconds.