Rename directory name using .htacess - .htaccess

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

Related

htaccess redirect from two domains

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.

Domain name point to subdomain of a entire different domain

I am completely confused the last few days with this and I still haven't found an outcome that's worked.
Basically I have a domain name without hosting at letshost.ie which is dublinplasterer.ie
I also Have one domain & hosting with godaddy for domain- shanafagan.com which is my own site for web/graphic design service.
I created a subdomain= dublinplasterer.shanafagan.com and uploaded the site files.
Basically I want for example when someone types in dublinplasterer.ie in the address bar if goes to dublinplasterer.shanafagan.com but doesn't show dublinplasterer.shanafagan.com url, stays as dublinplasterer.ie
Im not even sure if this can be done at this stage. head is melted
shanafagan.com and the subdomain dublinplasterer.shanafagan.com have the same ip so how will that work if changing dns?
Any help would be greatly appreciated , am so stuck at this stage.
If you wanted to do it this way you would need a web server for domain2.com
Search for ProxyPass.
The way you should do this is add a second domain on your web hosting (cpanel for example) and point the other domain to this web server.
If you are struggling I recommend using a solution like cPanel that is widely used and simplifies much of the process. It is common enough you can google most issues.
So normally you would have started by making an add-on domain (instead of a subdomain) which would also create it's own subdomain anyway. To do that, you go to your cPanel in GoDaddy and find add-on domain, then make it "dublinplasterer.ie" (Don't add www. to it. Even though this name is hosted elsewhere, we will later go to your DNS files at that hosting and point it to your GoDaddy's name servers and this add-on helps it direct to the right root folder) then choose your local root folder for that site (I think you can actually make this the same as your other subfolder already hosting your files and then it will just pull the same site) or you can pick a different subfolder and then make the add-on domain. This tells any request to this name server that if it is a request for "dublinplasterer.ie" it needs to send it to the subfolder you specified.
If you don't make the subfolder the same as the one you already made, you can either load the same content into your new subfolder or create a CNAME record telling this add-on to point to your subfolder instead but that is more complex so go with the other route.
Lastly, you need to go to your original hosting at letshost.ie and under your domain name find the DNS records tab. Change the name servers to match your GoDaddy ones and now (may take a day or two to show as DNS changes often take days and can't be seen immediately but you can try using a different device/computer/mobile that hasn't loaded it previously to see if it will refresh the correct dns) it should work. Even though it points to your main site name servers, the add-on domain you made receives it and directs it to the subfolder you specified on the add-on domain.
Hope that helps, let me know if it works for you.

htaccess stealth redirect domain A to domain B

Hi is it possible to stealth redirect a domain to another domain and in the meanwhile keeping the url of the first domain visible in the address bar?
Using cPanel and able to edit htaccess
I am not sure that this is possible, but you can instead do the following:
Use iframe in order to display the destination website inside your current website in "full screen". Read this for more information.
Point your domain name to the ip of the destination. This might not work if the destination uses virtual host, but you can try. Try using the same the sub-domain if this doesn't work.

Point subdomain to another domain in the server

I have a server with Plesk and CentOS.
http://cdn.oyunlar1.com/images/8836.jpg file is located in server A.
http://www.oyunlar1.com/modaokulu.html file is located in server B.
I basically want the same thing except I want to locate media files in a different domain instead of different server. Like this:
user visits cdn.mydomain.com/file.swf
but they actually read files from mydomain2.com/file.swf
I tried changing IP of A record of the subdomain to mydomain2.com's IP but it didn't work.
How can I do it?
Edit: I want to do this because it will help me to change my hosting provider very quickly and easily becuse media files are +100GB and the rest is like 10MB.
Solution was simply adding CNAME record to mydomain.com of mydomain2.com and using htaccess at mydomain2.

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