PDA

View Full Version : مبتدی: مشكل هدايت مجدد با تابع header



sahar15125
جمعه 09 مهر 1389, 13:27 عصر
با نوشتنه دستور زير



header('Location: /index.php');

به جاي هدايت به صفحه ايندكس با پيغام خطاي :
Warning: Cannot modify header information - headers already sent by (output started at F:\wamp\www\redirection.php:2) in F:\wamp\www\redirection.php on line 3

مواجه مي شم ؛ لطفا راهنمايي كنيد؟:ناراحت:

shahriyar3
جمعه 09 مهر 1389, 14:06 عصر
اين 2 خط و ابتدا و انتهاي كدتون بزاريد درست ميشه


ob_start();
ob_flush();
ولي ....
براي استفاده از ريدايركت بجاي تابع هدر از راه هاي ديگر استفاده كنيد


<meta http-equiv="REFRESH" content="5;url=http://www.another-domain.com/another-page.html">




<script type="text/javascript"> <!-- window.location = "http://www.this-domain.com/newpage.html" //--> </script>

Read more: http://techblissonline.com/redirection/#ixzz11CZ3Vozi


ريدايركت با استفاده از كلاس هاي pear


<?php
require_once 'HTTP.php';

HTTP::redirect("/foo.php");
?>


و تابع

http_redirect ( $url)

NR_Nazifi
جمعه 09 مهر 1389, 18:58 عصر
اگر ایندکس در روت است نیاز به / نیست