Geçerli sayfaya yönlendirme

3 Cevap

Başka bir URL'den gelen kullanıcıyı yönlendirmek için en iyi yolu nedir?

Ben 2 konumları var.

http:mysite.com http://public.mysite.com

I want the users who type http://mysite.com to be redirected to http://public.mysite.com It would have been easy if there were 2 different index.php files, but the index.php file is the same in both the cases.

3 Cevap

Mysite.com On:

    <?php
    $url = “http” . ((!empty($_SERVER['HTTPS'])) ? “s” : “”) . “://”.$_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
    if($url != "http://public.mysite.com") {
       header("Location: http://public.mysite.com");
       exit;
    }
    ?>

Unutma exit;!

Good Luck,
Henrik

. Apache ile yapılabilir htaccess, böyle bir şey:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^\.mysite\.com$
RewriteRule (.*) http://public.mysite.com/$1 [R=301,L] 

Neden kolay olan javascript denemiyorsunuz

<script> window.location.href = "http://public.mysite.com"; </script>

Mutlu kodlama