I have been having some problems with my domain, when it reaches my server the address changes to my IP.

I 'own' the domain, "www.domain.com" which is forwared to my router, my router then points it to my server and the pages are displayed e.t.c.
Instead of displaying, "www.domain.com/index.php" it displays my IP, "XXX.XXX.XXX.XXX/index.php". This is obviously not what I want and isn't something that a user would expect.

As far as I am aware, I shouldn't need to setup a DNS as it is only going to one website? The domain should remain in the URL bar instead of changing to the IP.

As the title suggests, it is a LAMP server running Ubuntu 12.04 (latest version with updates).

Thanks for any help!

If the URL is changing, there is a redirect happening somewhere in the process (as early as the router, or on the webserver itself).

Thanks JorgeM,

Would that redirect be through the firewall, on the router I am telling it to send all HTTP requests to the server?
If so, how would I solve this issue?
The IP which comes up is the IP of my router, when accessing the site from outside the network it sits in.

Thanks

So, depends. This issue is most likely happening on the web server itself. Since you are running Apache, you most likely have an .htacess file. This is where the rewrite and redirects may occur. However, a redirect can also occur within the web page itself as you can redirect wtih a <meta> element or even javascript code on the page.

I only mention that it could happen before the web server if you had some device infront of it doing some type of application level filtering. I wouldnt tend to think its your internet router. Havent seen that feature there.

How about at your registrar? When you created the zone? Did you just create a standard DNS record to point to your public IP address, or did you use some tool at the domain registrar to do some type of redirect?

Somewhere, there is a redirect happening. When you type in the host name in the browser, the browser is connecting to something and that something is telling it to directly use the URL that includes the IP address. I am pretty confident.

Start by inspecting your web server config and index.php to make sure that there isnt a redirct within the. I am not an expert on Apache/PHP, but do know IIS/ASP.NET pretty well. Either way the concept is the same.

Thanks for the continued help JorgeM,

In terms of my domain registrar (123-Reg.co.uk) I just purchased the domain and then within the web control panel which they provide, I select the domain which I want to forward and then type in the IP of my router.

From my router, any HTTP request gets sent to my server where Apache handles it.
I don't think it is the .htaccess file because Apache ignores anything in the /var/www directory (by default and I haven't change any settings) which is where my files are stored.
So unless it is a problem with not having them involved then I am a bit baffled.

When you say, 'a redirect can also occur within the web page' are you referring to something like <?php header('Location: ../index.php'); ?>. I Do have a few of those although I am not sure that is what you mean by 'redirect'?

Thanks again for the help.
It isn't a security problem (from what I can see), just a bit annoying to have it miss off the domain name.

Ok, so I understand the process you have in place to get the web traffic into your network. You have a common approach.

What I mean by redirect, is literally that. Redirects are common for many scenarios. Here is one that you can easily understand....say I have 5 domain names, but I want for my visitors to be directed to my "main" domain name regardless of which URL they typed in the browser. You would put in HTTP redirects (either 301 or 302-depending on the scenario) so the user's URL in the browser shows the main URL.

While I am by no means a web expert, your description to me just seams like you are redirecting to the IP address. Where this is ocurring, is difficult for me to tell you. You would be able to figure this out if you had an internet client, run a packet capture and see where this is actually occuring.

I am not up to date on PHP, but your example seems to me like a relative URL. That's not what I was referring to. Coding your site with relative URLs, allows you to basically run the web using any domain name.

The reason why I mentioned your registrar is because many of them provide a "free" service that you can use to redirect domain names (also known as domain forwarding).

Ok,
I shall continue looking into this, thanks again for the help.

Just looking at the configuration panel from 123-Reg.co.uk and to forward it to my site it indicates I could either use 301 or 302 redirect.

From your hosted config panel, the forwarding should be blank or not enabled in your case.

Then how would I point the domain to my web server?

I've just had to sit through the painful experience of customer support, but I did finally get an answer out of them and they said I needed to use 302 framed forwarding which seems to work fine now.
Although I for some reason had to put in my meta keyword tags e.t.c. and my favicon on the 123-Reg config panel instead of placing them in my web pages.

Thanks for all the help regardless JorgeM.

It looks like they are intercepting the traffic prior to forwarding to your web server. Glad to hear you resolved it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.