Print Page | Close Window

.htaccess rewrite

Printed From: openElement Website
Category:

openElement


Forum Name: openElement General Discussion
Forum Description: A place for general discussion and questions about the software.
URL: https://forums.openelement.uk/en/forum_posts.asp?TID=1408
Printed Date: Apr 16 2024 at 7:42am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: .htaccess rewrite
Posted By: wads24
Subject: .htaccess rewrite
Date 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.   



Replies:
Posted By: nancywilson
Date 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 https://avastsupportnumber.co.uk/avast-customer-support/" rel="nofollow - avast customer service for the help purpose but did not get any response.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net