Jump to content

[SOLVED] URL Forwarding Problem.


ICONISE

Recommended Posts

Hey guys,

 

Im having a problem which hopefully you guys can help me out with.

 

I have Dada mail installed on my website which works absolutely fine on my website if used from http://www.iconise.net

 

But... if I use http://iconise.net problems start to occur.

 

My hosts say that it is not possible to auto forward everything to http://www.iconise.net and they say I would need as php script to forward from http://iconise.net to http://www.iconise.net.

 

The only forwarding script that i know is an OnLoad forward to.... but this causes a loop where the page refreshes, can someone please point me in the right direction on how to fix this please?

 

Many thanks in advance.

 

Link to comment
https://forums.phpfreaks.com/topic/41461-solved-url-forwarding-problem/
Share on other sites

Save this as a php file and include it at the top of all your pages to force the user to the www path for all pages.

 

<?php

if ($_SERVER["SERVER_NAME"]=='http://iconise.net') {
  header("Location: http://www.iconise.net".$_SERVER["REQUEST_URI"]);
}

?> 

Save this as a php file and include it at the top of all your pages to force the user to the www path for all pages.

 

<?php

if ($_SERVER["SERVER_NAME"]=='http://iconise.net') {
  header("Location: http://www.iconise.net".$_SERVER["REQUEST_URI"]);
}

?> 

 

I have tried this, although I cant get it to work.  I have saved the php in a file called forward.php

 

and im using:

 

<?php require_once('forward.php'); ?>

 

at the top of my web page.

 

Is this right? Im pretty new to PHP so sorry if this is a little dumb.

I have spoke to support once again and they say that this is not possible on server level.  They are using Zeus Web Servers.

 

They cannot change mod_rewrite. as that is Apache only.

 

Does anyone know a solution that can be achieved code wise?

 

Yeah that has solved the problem, when I used:

 

<?php echo $_SERVER["SERVER_NAME"]; ?>

 

It returned 'iconise.net' without the 'http://' prefix.

 

I simply removed the 'http://' prefix from the original code from Mjdamato

 

The working code is:

 

<?php

if ($_SERVER["SERVER_NAME"]=='iconise.net') {
  header("Location: http://www.iconise.net".$_SERVER["REQUEST_URI"]);
}

?>

 

Many thanks to Mjdamato.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.