Make original site url name to some fake url name - .htaccess

I am new to rewrite site url name. I have a site url like http://66.15.101.250/test/ . this is my owned server link So i want to change this site url to something other name like http://testsite/test/ ( i do not want to give domain name to this ip address url).And i have otheres site running on this http://66.15.101.250/test/ server . I have no idea how to do this, what should i do.
Is this possible through .htaccess file or something else
Thanks in advance

Your server can only respond to requests it receives, and will only receive requests routed to it by DNS, so if you don't own the domain name, you can't receive public traffic directed towards it. You could silently redirect users from
http://66.15.101.250/test/ to the content found at http://testsite/test/ but they would still see the http://66.15.101.250/test/ url in their browser.
If you think about it, its a good thing you can't do this or I could make stealyourcreditcardinfo.com appear as paypal.com. Indeed most uses for what you are asking about would not be legitimate ones...
For your own internal testing purposes, you can make virtual host entry for testsite.com and your server will respond to any requests it receives for testsite.com. You then change your HOSTS file to point testsite.com to 127.0.0.1 and testsite.com will work in your browser, but only on your machine because you manually overrode your own DNS. The DNS everyone else is using is still pointing testsite.com to the actual IP address somewhere else

If you need this for testing purposes (as it seems to me), you can put 66.15.101.250 testsite in your hosts file and configure a virtual host for testsite in your webserver.

Related

Can rocket.chat be server on 2 interfaces at the same time?

here is the situation,
we have a domain, let's say example.com
I have added a subdomain to the dns, chat.example.com
I have modified the Caddyfile inserting http://chat.example.com (it works fine)
However, rocket.chat is hosted on our local server, and it is behind the router provided by our ISP, which apparently is programmed to return its own home page if an address is typed that resolves to its external ip address. In other words, if a computer located inside our local network types http://chat.example.com, it gets the router home page (the one where you can configure it).
I have solved it by modifying the hosts file, but I would prefer a cleaner solution. Is there anything that I can do on the Caddyfile, perhaps allow him to reply on 2 interfaces (http://chat.example.com and http://192.168.1.x), or something else that I have not thought yet?
Thank you!

How does my local HOSTS file resolve but IP will not

I'm in the process of launching a new website. I migrated all the code to the new server. The admin at the new host told me that I have to add an entry to my hosts file and then I will be able to see the website. So essentially he had me add:
111.222.3333.4444 example.com www.example.com
These are example, but after doing this, it worked. My question is, is how? If I visit the IP directly in my browser I get a 403 Forbidden error. Does the host have a way to resolve this IP to a location on their server if resolved from a domain name? I'm just confused as to how this works. I understand that by changing the IP address I can get the domain name to resolve to any IP, but I'm wondering why, on the hosts end, does this now resolve this way, but not by typing in the IP directly.
Thanks!
Does the host have a way to resolve this IP to a location on their
server if resolved from a domain name?
Not exactly. Your browser, when sending the request to the IP address, will send one important piece of information called 'Host header', that is the actual host name as you typed in your browser.
You usually can not open the website just by entering the IP address in your browser's address bar because web servers (and possibly many other network components that are between you and the web server) often do not host only one web site on that IP address so they rely on exact domain name typed in address bar to serve the right content.
You can test this by using one of the browser add-ons that allow you to add your own headers. Add header named 'Host' with the value 'example.com' and with that try to open your site by typing only provided IP address.

One domain (www.example.com) different paths (/ vs. /server2) go to different servers?

I'm wondering if it's possible to host an application on one server (S1) with the root directory of a domain (example.com/) as its approot, but have a TOTALLY DIFFERENT application on another server (S2) with its approot pointing to a specific path of the same domain (example.com/server2).
I'm not talking about subdomains; I'm not talking about load-balancing one application. I'm talking about example.com/* pages on S1, and example.com/server2/* pages on S2. Anyone have any ideas? Thanks!
I'm not familiar with the term "approot", but suspect it is the name of some configuration at the webserver end. It's better to think about these kinds of question from the other end: how will a message get from the browser to the right server. The user gives the browser a URL; the hostname in the URL is looked up in DNS to find an IP address; an HTTP request is sent to that IP address, with the requested path in it.
So ultimately, you have to have some server (or set of interchangeable servers) serving the whole of example.com, because that's the only part that will be looked up in DNS.
That server could, however, be a proxy, which looks at each request it receives, and passes it on to another server based on some configured rules.

How do I redirect to a shared virtual hosted site in the hosts file?

I want to change my hosts file to redirect a web address to my site...
normally I would just do... ping mysite.com then in the hosts file, if the IP came out as 99.99.99.99, I'd write...
99.99.99.99 siteiwanttoredirect.com
But in this case my site is on virtual shared hosting... which means the IP I get back from the ping is the same as a few other sites and if I type that IP in the address bar, www.mysite.com won't come up. Here's a bit more details: someone who asked a question about why pinging it wouldn't give the correct IP.
So what I would like to know is... if you're on virtual shared hosting, how can you specify redirects to your site in the hosts file?
Thanks,
Matt
You cannot. With the hosts file you can change the IP address, but your shared hosting provider needs the HTTP Host header to be set up correctly -- which in your case will still be siteiwanttoredirect.com and not mysite.com . Your hosting provider will therefor not know who's site to show.
What you could do is redirect to some host you control (f.i. localhost) and run a proxy server there. If you set up Apache on your machine, with a virtual host for siteiwanttoredirect.com which does a reverse proxy to mysite.com , it should work.
This is handled via the host header of the website, and not anything on your local machine, like your hosts file.
I would make sure your host has that set up, then as long as people visit your sit via the website name, and not IP, everything should work.
On a shared host, the website you get is determined by the domain name you ask for thanks to the Host HTTP header. For this to work properly the web server needs to be configured correctly so it knows what website to serve in response to which Host request - this is usually called 'Add-on Domains' on CPanel driven shared hosting.

How to redirect different sub domain requests to different servers

Under my domain, one of the subdomain must be directed to one server that hosts the relevant applications, and the rest must be directed to another server that hosts the relavant applications.
So, any requests to the url appa.example.com\* must be directed to one server, and any requests to the url appb.example.com\* must be directed to another server.
The issue now is how to configure the Apache configuration on both servers-- maybe using configuration like ProxyPass or ProxyPassReverse so that they all the incoming requests can be directed correctly at the correct server?
Edit to make the question clearer.
The place to link an url to an IP (server) is the DNS.
For example if server A is at 1.2.3.4 and server B at 5.6.7.8 you link appa.example.com to 1.2.3.4 and appb.example.com to 5.6.7.8.
But if both servers are behind a firewall (with a single external IP address) you have to perform some tricks. (And you are probably looking for these tricks).
Have a look at An Introduction to Redirecting URLs on an Apache Server.
I've done the same thing for my workplace (a University). Our primary website it hosted elsewhere but part of the site (student registration system) is hosted onsite.
What I did was to create a Authoritative (A) DNS Record (reg.domain.com) and made it point to the IP of our onsite server. And that did the trick!!!
Here's a screenshot of the same from my domain CP (domain and IP masked for obvious reasons)...
alt text http://img443.imageshack.us/img443/5069/stiuaregrecord.jpg
It's essentially the same as what you're trying to do. Give it a shot and see :)
In the DNS records/manager for the parent domain of the intended subdomain:
point the subdomain name at the to-be host servers IP address, then ...
... Then ...
In the host server DNS and or server-software config: direct the subdomain to the website app. You can achieve this by one of: -
manually edit the DNS records,
park the subdomain and point it at the website document root folder, or
add the domain and subdomain (domain will never be used since its not pointed at applicable server). Point them both at the document root for your now subdomained (if there is such a word) website app

Resources