htaccess redirect from two domains - .htaccess

I have two domains, lets say www.A.com and www.B.com which are located on the same server. The directory is like this:
/html/index_of_A.php
/html/content_of_b/index_of_B.php
Now i want to configure an .hataccess file, which does the following things:
1) redirect users which enter A.com to /html/index_of_A.php (which is actually www.A.com) and
2) redirect users which enter B.com to /html/content_of_b/index_of_B.php
At the end, users enter two domain names (a.com and b.com) and they are getting redirected respectively to the specific folders of the domains.
Is that possible with htaccess?
The reason for this is, that i have two domain names, but they are on one server. Now I want to seperate both of them, to make "two different web pages".
Further, the users should always get rediretet to the www version.
Unfortunately I have no idea how to do that... I did some searches and tried different methods, but no success :(
Hope anybody can help me, appreciate that!

If I understand you problem correctly, there is no need to configure an .htaccess file.
You can solve your problem by slightly reorganizing your folder structure.
This is how I would solve it:
[folder for domain A/index.php]
[folder for domain B/index.php]
Configure your domain registration for www.A.com to point to [folder for domain A]
Configure your domain registration for www.B.com to point to [folder for domain B]
This way there is no need for an .htaccess file unless you are setting one up for security reasons (not redirection) AND you don't have to muddle through www.A.com's files when you need to focus on www.B.com.
I hope this helps.

Related

htaccess rerouting multiple domains to one subfolder on the same level with a static value pass through

I know there are many .htaccess questions and aswers here and on the internet, but I can't find the answer in all the noise I am looking for. I am on a shared server. If you go to domain abc.com it access folder abc. IF you go to domain def.com it access folder def. What I want is if you go abc.com it must reroute the domain to folder def and send it a static value saying this is from abc... in that way I can have multiple domains access the same code in one folder and don't have to duplicate the code over and over again. Any ideas and solutions and comments will be extremely welcome and deeply appreciated. thanks

Can two Squarespace websites be of the same subdomain, with a slash

so my issue is as follows:
I have a website, on one language pointing to a site subdomain.domain.com. I added CNAME records and it points perfectly. I now have another squarespace page that is the clone of the other one, only in a different language. Is there a way to point it to subdomain.domain.com/en , for example, and how would one go about doing this thru squarespace and my hosting sites webmin.
You can't use same subdomain for more than once. But as you own, and have access to that domain you can make different subdomain. So it can be: subdomain.domain.com and ensubdomain.domain.com or even you can have subdomain of subdomain en.subdomain.domain.com. You are probably aware where it goes. You can have something like: you.can.go.as.far.as.you.need.or.you.want.domain.com. ( be aware that you need to check with host first, what is included in your package or maybe do you have some limits)

Rename directory name using .htacess

It's hard to explain, I would like to do something like below but I don't know how.
I currently own two different domain names and have one website.
Can I have two domains pointing to the same website but the URL only shows whatever domain is entered in the first place?
For example, when I type in 'domain123.com', it takes me to my website (IP address 111.222.333) with the URL shown as 'domain123.com'. Then when I type in 'domainABC.com', it also takes me to the same website (IP address 111.222.333), but the URL needs to show 'domainABC.com' instead of 'domain123.com'.
I guess I will need to redirect one of the two domains to the website, but how can I stop the URL changes the domain name?
I am not sure if I can just modify .htaccess to achieve above or if I also need to change the DNS, etc. to make this work.
Please help and many thanks
It depends on your setup and your server permissions.
A nice way will be to change the docroot in the apache or nginx config.
If you don't have permissions to edit these configs, you can create a symbolic links so that the public folder of domain2 points to the public folder of domain1

How can I display a subpage of my Silverstripe website as a subdomain?

I have a website build on Silverstripe 3.
Now I want that a user can enter the Subdomain URL info.mydomain.com and see the content of the page mydomain.com/subpage-url/. But without redirection. The subdomain URL should stay in their browser.
I already created the subdomain and let it point to the root directory of my website. As I understand it right I now need some rewrite conditions in my .htaccess file? And that is the point I struggle with. I googled a little bit and did some trail and fail but nothing seems to work. Maybe I understand it totally wrong, used the wrong rewrite conditions or insert them on the wrong place.. Maybe there are Silverstripe specific issues to pay attention to?
Long story short: I need help please!
As Robbie Averill pointed out in his comment, you could install the Subsites module. But you'd have to create a Subsite (eg. a separate site-tree) for every domain.
There's another module though, the homepagefordomain module. With that module you can specify one (or multiple) domains per page. When you visit one of these domains, the page that was specified as home-page for that domain will show up. I think this is a more flexible approach than messing with the .htaccess file.

redirect non existence url to folder

i am a user, and i type: www.japsomething.com, that url doesn't exist however there is a folder called "something" and i want this url to point to that folder?
do i need to purchase the domain name for this to work or i can use .htaccess?
i still would like to preserve the url. so this means, even though i am coming from
www.japsomething.com the url should still say www.japsomething.com and when i click anything on the site it should say www.japsomething.com/anything/
another question is, how can i detect based on the users ip that i want to show them a spanish site, or an english site?
thanks for your responses.
do i need to purchase the domain name for this to work or i can use .htaccess?
You need to purchase the domain name, because otherwise when someone types: www.japsomething.com, their DNS is going to try to look that name up, and if you don't own that domain, the request is never going to reach your server, thus, your htaccess file is never even used. Because you don't own every domain that starts with "jap" and ends with ".com", you can't use htaccess to do this.
i still would like to preserve the url. so this means, even though i am coming from www.japsomething.com the url should still say www.japsomething.com and when i click anything on the site it should say www.japsomething.com/anything/
If you own the "japsomething.com" domain, you simply point it to the server and directory that contains all the content, and then be done with it. No htaccess trickery is involved here. If you went out and bought the "japsomethingelse.com" domain, simply point it to the directory that serves that.
another question is, how can i detect based on the users ip that i want to show them a spanish site, or an english site?
See mod_geoip2 for downloads and examples.

Resources