tags:

views:

40

answers:

3

hi,

i am having a 2 Urls like http://www.abc.com and http://www.xyz.com.

I am trying to redirect to http://www.xyz.com whenever i type http://www.abc.com in the browser.

And also when the user types http://www.abc.com/index.php?option=com_content&view=article&id=46&Itemid=55 something like this ie. any query next to abc.com then i am trying to redirect to http://www.xyz.com/index.php?option=com_content&view=article&id=46&Itemid=55.

how to do this in Php... Please help me..

EDIT: i wrote a script in php in my template file to redirect as

 <?php
   if(curPageURL()=="http://localhost/joomla/Joomla_1.5.7/"){
     header("Location: http://localhost/joomla/Joomla_1.5.7copy/");


   }
//   else if(curPageURL()=="http://localhost/joomla/Joomla_1.5.7/"){}

      function curPageURL() {
      $pageURL = 'http';
       if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
       $pageURL .= "://";
        if ($_SERVER["SERVER_PORT"] != "80") {
        $pageURL .=         $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
        } else {
              $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
     }
   return  $pageURL;
   }

 ?> 

In the else if i am trying to check if the "http://localhost/joomla/Joomla_1.5.7/" has any queries next to the url like "http://localhost/joomla/Joomla_1.5.7/index.php?option=com_content&amp;view=section&amp;layout=blog&amp;id=3&amp;Itemid=55"

so that i have to take the query next to it and to attach the same to http://localhost/joomla/Joomla_1.5.7copy/index.php?option=com_content&amp;view=section&amp;layout=blog&amp;id=3&amp;Itemid=55.. Please help me

+1  A: 

You will have to setup .htaccess file, have a look at this for more info:

http://httpd.apache.org/docs/2.0/misc/rewriteguide.html

Sarfraz
+1  A: 

use Header("Location: http://wwww.xyz.com") however better redirection is done using .htaccess see http://corz.org/serv/tricks/htaccess.php for some information about that.

Kolky
A: 

Example on how to use .htaccess rewriting to redirecting.

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.+)\.htm$ http://www.xyz.com/$1.php [R,NC]

Read the rewrite guide mentioned in the answer from Sarfraz, its a good reference!

Doing this in PHP, will only slow this down, for it requires a second degree of parsing, if you only need redirection.

Shyam
its not working shyam .. pls see my edit..
Aruna