PHP Script url yönlendirme için

3 Cevap php

i http://www.abc.com ve http://www.xyz.com gibi 2 Url'leri yaşıyorum.

Ben tarayıcıda http://www.abc.com yazdığınızda http://www.xyz.com yönlendirmek çalışıyorum.

Ve de bu ie gibi kullanıcı türleri http://www.abc.com/index.php?option=com_content&view=article&id=46&Itemid=55 birşey. sonraki abc.com herhangi bir sorgu ardından i http://www.xyz.com/index.php?option=com_content&view=article&id=46&Itemid=55 yönlendirmek çalışıyorum.

Php bunu nasıl ... Lütfen bana yardımcı olun ..

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;
   }

 ?> 

Else i http://localhost/joomla/Joomla_1.5.7/ gibi url sonraki herhangi bir sorgu olup olmadığını kontrol etmeye çalışıyorum eğer http://localhost/joomla/Joomla_1.5.7/index.php?option=com_content&view=section&layout=blog&id=3&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&view=section&layout=blog&id=3&Itemid=55..

3 Cevap

Sen kurulum .htaccess dosya zorunda kalacak, daha fazla bilgi için bu bir göz:

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

Bu konuda bazı bilgiler için) Header("Location: http://wwww.xyz.com " however better redirection is done using .htaccess see http://corz.org/serv/tricks/htaccess.php kullanın.

Yönlendirme için. Htaccess yeniden yazılmasında nasıl kullanılacağı hakkında bir örnek.

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

Sarfraz, onun iyi bir referans gelen cevapta belirtildiği yeniden yazım kılavuzunu okuyun!

Bu ayrıştırma, ikinci derecede gerektirir için sadece yeniden yönlendirme gerekiyorsa PHP bunu yaparken, sadece, bu yavaşlayacaktır.