How to change the root file on htaccess - apache

Because of my host system I have different folders for some domains(domain.com, domain2.com, domain3.com)
DomainFolder
DomainFolder2
DomainFolder3
Every domain should point to Domain, but the host told me that they work only in that way for multiple domains and that I should write a .htaccess on Domain1, Domain2, etc to send that domains point to DomainFolder.
How can I make that a htaccess changes the request file from DomainFolder1 to DomainFolder?¿?¿?¿?¿?

Related

How to use .htaccess to redirect sub domain to another folder, not URL

I have hosting with no domain pointing to it at present (because I changed the A record to point to another host).
How can I use .htaccess to point my subdomain to the root of the hosting? Also, can the .htaccess file sit in the subdomain's folder because if it goes in the root, I assume it won't be called because the domain points elsewhere.
My folder structure is like this:
the root is: /httpdocs
the subdomain is: /subdomains/old/httpdocs
I hope I am not mistaken when I read the question. Here you can't use .htaccess to point your subdomain to the root of the hosting.
On your case you can point your subdomain to the root of the hosting by setting your subdomain exactly the same IP address before you changed your A record.
Say old setting of your A record it point to IP 123.123.123.123
A 123.123.123.123
Now say you have change your A record point to another host say IP 456.456.456.456. So all you need is set your sub domain to the same IP of your A record before it was changed.
A 456.456.456.456
subdomain 123.123.123.123

Redirect .co.za to .com - 2 domains sharing the same root folder and htaccess file

I have 2 domains:
mysite.co.za and mysite.com
the mysite.co.za domain is an addon domain which shares the same root directory as the mysite.com domain. So both mysite.co.za and mysite.com load the same website files.
Is there perhaps a way that I can redirect the .co.za addon domain to the .com via the .htaccess file even though both domains share the same .htaccess file?
Any help in this regard would be appreciated.
You can redirect entire domain names through your DNS provider. I recommend that approach, doing it on the domain server level would probably evoke better performance than having to traverse all the way to your server for the re-direct.

htaccess multiple domains on one hosting using subdirectories

I've been trying to make the following thing work for hours, with no luck:
I have a vps hosting at digitalocean running ubuntu and xampp, and I have multiple domains pointing to the same ip address.
What I want to do is load files from different subdirectories for different domains.
So when I enter domain1.com into the browser, it loads the files from /htdocs/domain1/, and domain2.com from /htdocs/domain2/.
I've found several examples about this, but all of them had the same problem when I tried accessing subdirectories like this: domain1.com/test, they all redirected me to domain1.com/domain1/test, and I do not want to see the middle part domain1 in the url.
Is it even possible?
I've tried all the answers scattered around the internet searching for "multiple domains on one hosting htaccess", and "htaccess hide middle part of url".
Thank you for reading.
Assuming you're using apache as webserver:
define a VirtualHost for each domain, or host in domain. Give each VirtualHost as ServerName the host- or domain name you want to associate with it.
specify a different DocumentRoot for each VirtualHost. The DocumentRoot is the path to the actual files.
add the hostnames you want te be able to access the web files under to your DNS zone.
When done correctly, you will be able to access the web presence associated with each host- or domain name, without the need to enter any subdirectories in the URL, nor will their names show.

htaccess to redirect a specific path on any subdomains to a specific path on the main domain

I have one .htaccess file (all subdomains point at the same file directory as the main domain, so one .htaccess file would need to accomplish this). What I'm trying to do is this: any current and future subdomains should redirect like so:
sub1.example.com/cart
sub2.example.com/cart
sub3.example.com/cart
unknown_future_subdomain.example.com/cart
Those 4 subdomains and specific /cart path should all redirect to example.com/cart
I have tried different solutions but they caused redirect loops, I think because the sames .htaccess file is loaded on the main domain.

Serve main directory from subdomain URL without redirecting

I have a http.//domain.com served at /var/www/domain
I also a http.//subdomain.domain.com served at /var/www/domain/subdomain
When a user visits http.//subdomain.domain.com i want apache to serve /var/www/domain
I have been looking everywhere and have found solutions from within the virtual hosts declarations with an Alias
But as I am on a shared host, I cannot edit httpd.conf.
So i have to do it from .htaccess
The important part here is to not redirect the user, only serve the main domains directory from an htaccess.