Site running by the host entry - php

I am running one site by host entry and pointing out it to another server.
For example,
My site is www.example.com and I did host entry and pointing it to xxx.xxx.xxx.xxx IP.
When I run URL into browser it is pointing to new IP correctly but internal URLs, JavaScripts and images are calling from it's original old server.
Is it any server configuration issue or something else ?

In which technology the website is built with. May be internal URLs, JavaScripts and images are stored in database like in wordpress CMS?

Resolving hostnames to/from IP is a DNS issue. Perhaps your DNS cache is corrupted so try flusing your DNS.
https://www.whatsmydns.net/flush-dns.html

Related

Unable to access files and website with IP address

I have my site hosted on GoDaddy and working on an application which is developed in Code-igniter Php. In my application I am using a library Grocery Crud. But when ever it access url related to the assets files and other files it calls them by IP address. As far as it was on local server it was running fine but as soon as I deployed it up it came up with the problem.
I know as the particular IP address is shared among many sites so that's why particular problem is occurring. but how to solve this problem is it what or something need to be configured in code igniter or some where else?
I understand that you are in a shared hosting environment:
I know as the particular IP address is shared among many sites
That's why you cannot access your site with its IP address. It's not possible. Period.
There's nothing to configure in Codeigniter, because it's the configuration of the HTTP server. HTTP server handles requests.
When you type a url in your browser, it will resolve the corresponding IP address. Then it will request the IP address, saying what hostname you are trying to reach. Based on these information, HTTP server will be able to handle your request and send it to the appropriate website.
When you type an IP address in your browser, HTTP server will not know what hostname you want to reach. Depending on the configuration, it will do what it has to, but probably not send the request to your site: in shared hosting environment, there is no reason for hoster to send request to a specific website it hosts. It will most probably display a 404, 403 or redirect to their homepage.
Many hosting providers assign a temporary hostname for your website, generally as a subdomain of theirs. You should temporarily use this hostname for your website.
To configure this hostname, open application/config/config.php and set the base_url parameter.
You can load different configuration files depending on your environment (for example: development, staging, production). See Handling multiple environments in CI documentation.

DNS pre-resolve at server

Is there a way to resolve DNS at server (using PHP), then include that pre-resolved IP address with domain name in html? So client's browser fetches directly from that IP without having a need to resolve DNS first?
Here is a bit more clarification. My PHP generated page has many external links to js, css and image files from different domains. It takes much time when DNS is resolved on clients' browsers. It can be done very fast on server but I don't want to links those resources directly from IP address. Instead I want something that tells browser that the domain example.com is hosted at 1.1.1.1 for example and no need to perform a DNS lookup.
Is it possible? or can there be a workaround?
Some thing like dns-prefetch with a value or attribute?
<link rel="dns-prefetch" href="http://example.com" value="1.1.1.1" />
Thanks in advance.
Well, you can resolve dns-name to IP.
While PHP can't do this, you can create a test file on your server. After that you fetch request for his file. According OSI model, DNS client will resolve DNS name->IP, after that you will have IP in your HTTP headers, because your real query depend on IP of server.
Low level. Windows and Linux both have an API for resolving DNS name -> IP. So you can use their functions in C++ to get IP without test file.
Or you can construct DNS message: DNS-message => UDP-datagram => IP-package. After you send it to DNS-server and wait for answer.
Your DNS-server IP you can find in your config.

htaccess redirect url/domain to my server using ip address

I have a web server with a website on the root IIS7 So it is wwwroot/mysite. This web server has about 20+ websites on. So I have a domain and only have access to it via ftp. Its Apache LAMP based stuff.
So I need to redirect www.mydomain.co.uk to my IP address 107.xxx.xxx.xxx and then to the right binding all from a .htaccess file.
Is this at all possible? Sounds a bit hacky to me. Currently I am just redirect www.mydomain.co.uk to www.mydomain2.co.uk. Maybe there is a way to mask the url.
Thank you in advance for any advice on this.
Since you have a domain, you could set a subdomain that points to the IP address of your server (107.xxx.xxx.xxx) and have everything else point to the other server. Then, you can set up an A record (if you have access to DNS editing from your domain registrar -- not your website host), to point the subdomain to your IP address (I'm currently doing this on one of my subdomains to point to my linux VoIP box while everything else points to my website).
I honestly don't know if PHP alone can accomplish this, but I know from experience that DNS Zones can.

webpage hosted on a server which is pointed by separated domain name, how to hide original server path?

Am sure there's answer on Google but I don't know how to formulate my question:
A php website is hosted on server like this: http://sub.realserver.com/website/index.php
Now I want to link the real domain name to it: http://therealwebsite.com
Problem is, when user visits:http://therealwebsite.com, he will see http://sub.realserver.com/website/index.php as he browse through other pages.
Question is how do I hide this realserver path and replace it with the domain name?
Thanks
edit: the website is hosted on a different server as the real domain name
I presume the domain name and the web site are pointing to the same server.
Although you could use URL rewriting (works with almost all popular web servers), the better solution is to set up your web server to provide that web site for the root of that domain name. How to do that completely depends on what server software you are using.
In apache, you need to create a so-called Virtual Host, configure it to respond to your domain name and set its DocumentRoot directive to the directory where your site is located.
See http://httpd.apache.org/docs/2.0/vhosts/examples.html for an example.
EDIT: I just read your comment. I'm afraid your options are rather limited. The easiest solution, but also the most dirty one, is to create one page with an IFRAME on it, that loads the site from the real server. You could also host a PHP proxy and on the server that hosts your domain name, and let it proxy the site on your
http://sourceforge.net/projects/php-proxy/
(I never used this, nor am I affiliated with this project, but it seems to claim to do what you want.)
I highly recommend though that you update your DNS records on your domain name so that it points to your server that hosts your site, and that you add a virtual host there.
you can do this with asp, there is a good resource on it here -
http://weblogs.asp.net/scottgu/archive/2007/02/26/tip-trick-url-rewriting-with-asp-net.aspx

What others see as URL when we work with localhost changed in the hosts file?

Let me introduce to the situation we had to face it and the core of the question.
We needed in our project to change the "localhost" to be something else like "newdomain-localhost.com", so we changed the hosts file (in Windows) and everything worked.
We reached the wall of Facebook with its sharer, where you need to get the site into a whitelist if you want to share content like flash. It's allright with the production server, but what happens in the dev enviroment?
My question is: if I change the hosts file to get localhost into something like "newdomain-localhost.com", when a request is thrown from my local machine to a service like Facebook, Facebook will take the domain "newdomain-localhost.com" or directly the public IP of my machine (which in this case is fixed, but it can be dynamic)?
Let me add that I think it perfectly makes sense to say that the hosts is something that affects locally, and the service receives the public IP instead of the domain name.
Correct?
I'm not certain I grasp your question, but my best guess is it boils down to:
If I rename localhost to newdomain.example.com within the hosts file do external sites see that?
And the answer is catagorically: no
Your hosts file is simply used by your local machine to resolve addresses - it is not visible to anyone/anything outside of your local machine. Now if you put that data within a public DNS it would be a different story - but I won't complicate things by going off on that tangent * admires tangent *
What happens is the following: if you add/change something to your hosts file (/etc/hosts on linux, %windir%\system32\drivers\etc\hosts on windows), only your local PC will act differently because it first looks in this hosts file when it tries to find an ip-address for a host name. The host name will be sent with the HTTP request, so web servers can act differently for different host names with the same ip-address.
You might be interested in reading a bit about network address resolving (e.g. http://en.wikipedia.org/wiki/Domain_Name_System )
What exactly is your project doing? Are you talking about Facebook connect? What you are saying will work fine on your computer for Facebook connect, but only on the computers where you've modified the hosts file.
If you have Facebook connect set so your application goes to http://www.production.com, then you just need to add a line to your hosts file saying www.production.com is 127.0.0.1. When you click on the connect button the login window opens and that redirects you to the url http://www.production.com to set your connect cookies. Since your computer thinks that the IP for that site is 127.0.0.1 and since cookies are stored with host names and not IPs that works fine.

Categories