Two domains on one address

Having trouble installing serendipity?
Post Reply
Thomas
Regular
Posts: 130
Joined: Tue Sep 21, 2004 2:00 pm
Location: Stockerau/NÖ/A
Contact:

Two domains on one address

Post by Thomas »

Hi,

I registered today a new domain for my account at my provider and want to use that one as the main domain in the future. But I don't want to loose the requests which are sent to the first one.
I have now the idea to forward those requests to the new domainname,

Example:
http://www.example1.com/archive/1-Article.html
should be then forwarded to
http://www.example2.com/archive/1-Article.html

The location of example1.com is the same as example1.com. The same software and content should then be used. I know that I have to modify the index.php to check which domain is accessed. But I don't know too much how I can set the cheat in the code. Maybe one of you can help me.

Many thanks in advance, Thomas
Thomas
Regular
Posts: 130
Joined: Tue Sep 21, 2004 2:00 pm
Location: Stockerau/NÖ/A
Contact:

Post by Thomas »

Hi,

I solved the problem already myself. I wrote a little script that is included to the index.php at about line 15:

Code: Select all

...
header('Content-Type: text/html; charset='. LANG_CHARSET);

include_once('redirect.php');	

$track_referer = true;
...
The script can be downloaded at http://www.tomscorner.at/redirect.zip
Feel free to use it for your own purposes.

Instructions
The configuration is easy. Extract the content of the .zip-file (one php and one javascript file) to the root directory of where you have Serendipity installed to.
At line 6 of redirect.php you see the array variable $old_server. DonÄt change the datatype!
If you have also a short domain (example1.com) add the variables in that way:

Code: Select all

$old_server=array('example1.com', 'www.example1.com');
Change the $new_server variable to the value of the redirect should point to.
That's all. You can modify the content of what redirect.php should display, of course. There you see the tag <span ... id="COOL_REDIRECT"><digit></span>.
The id is necessary so that the javascript can find the digit which acutally also configured the value after which the user is transferred to the new page.

I hope that it works for others as well. My test runs were successful. I wrote it as general as I was able to.
Feedback is welcome, of course.

Regards, Thomas
Post Reply