การ redirect โดย php header("Location: url"); นั้นสามารถทำได้ทุก browser มั้ย?

เริ่มโดย hikizume, 18 กันยายน 2008, 11:52:38

หัวข้อก่อนหน้า - หัวข้อถัดไป

0 สมาชิก และ 1 ผู้มาเยือน กำลังดูหัวข้อนี้

hikizume

ตามหัวข้่อเลยครับ

อยากรู้ว่า browser สามารถ block การ redirect แบบนี้ได้มั้ยครับ
ถ้าได้

งั้นผมขอวิธี redirect ที่ได้ผล 100% ด้วยนะครับ  :-*

ขอบคุณครับ

EThaiZone

ตามหลัก บล็อกไม่ได้ครับ เพราะเป็นคำขอเปลี่ยน location
จึงไม่มี refer หรืออะไีรให้ตรวจ

แต่ถ้ามีเงื่อนไขอื่นประกอบ ก็สามารถทำได้ในบางเคส (ตรงนี้ไม่ขอพูด)

สรุปคือยังไง มันบล็อกไม่ได้ครับ

:)

hikizume

ขอบคุณครับ

สรุปคือผมสามารถมั่นใจได้ 100% เลยใช่มั้ยครับว่า

user ของผมจะไปถึงยังหน้าปลายทางแน่นอนครับ

EThaiZone

ใช่ครับ เพราะคำสั่งนี้ มีผลกับ browser โดยตรง

avatar ผมก็ใช้ header location เหมือนกัน
สุ่ม array แล้วค่อย location ไปเว็บฝากรูป

เหตุเพราะไม่อยากเปลืองแบนวิท  :D

hikizume

ขออีกคำถามครับ

แล้วถ้าจะ redirect โดย pass referrer ไปด้วยนั้นสามารถทำได้มั้ยครับ  :'(

EThaiZone

อ้างถึงจาก: hikizume ใน 18 กันยายน 2008, 12:41:10
ขออีกคำถามครับ

แล้วถ้าจะ redirect โดย pass referrer ไปด้วยนั้นสามารถทำได้มั้ยครับ  :'(

ไม่เก็ทครับ หมายถึงยังไงเหรอ  ???

hikizume

อ้างถึงจาก: EThaiZone ใน 18 กันยายน 2008, 13:12:35
อ้างถึงจาก: hikizume ใน 18 กันยายน 2008, 12:41:10
ขออีกคำถามครับ

แล้วถ้าจะ redirect โดย pass referrer ไปด้วยนั้นสามารถทำได้มั้ยครับ  :'(

ไม่เก็ทครับ หมายถึงยังไงเหรอ  ???

ปกติเวลาเรา request ไปที่ server มันจะมี header ที่ชื่อว่า referrer ใช่มั้ยครับ
ถ้าเป็น php จะใช้

$_SERVER['HTTP_REFERER']

ในการดูค่าครับ

แต่ทีนี้ถ้าสมมุติผมส่ง user ไปหน้า A user คลิกลิงค์ในหน้า A ไป B
ณ ขณะนั้นถ้า B จะได้ค่า referrer มาค่านึงคือ A

แตุ่ถ้าหน้า B ทำการ redirect ไปหน้า C นั้น
referrer จะไม่ส่งตามไปด้วยอะครับ

GAPZiNE

[direct=http://www.powermaxradio.com]วิทยุสื่อสาร[/direct]
[direct=http://www.gapzine.com]ออกแบบเว็บไซต์ ทำเว็บไซต์ webdesign[/direct]
[direct=http://www.sahaphan2002.com]ถังขยะพลาสติก[/direct]
[direct=http://www.two-way1.com]วิทยุสื่อสาร[/direct]
[direct=http://www.worldwireradio.com]วิทยุสื่อสาร[/direct]

EThaiZone

มีทางคือ หน้า2 ต้องทำอย่างอื่นที่ไม่ใช่ header location เช่น

<script>window.location="3.php";</script>

:)


hikizume

อ้างถึงจาก: EThaiZone ใน 18 กันยายน 2008, 17:16:38
มีทางคือ หน้า2 ต้องทำอย่างอื่นที่ไม่ใช่ header location เช่น

<script>window.location="3.php";</script>

:)



ขอบคุณครับ

แต่ว่าถ้ากรณีที่ user คนไหนปิดการ run java script ของ browser ไว้ก็จะไม่ไปถึงปลายทางได้

เฮ้อ... ได้อย่างก็ต้องเสียอย่าง :-X

EThaiZone

ทุกอย่างมีทางเลือกเสมอ (ฮา)

<meta http-equiv="refresh" content="0;URL=3.php" />

:D :D

hikizume

อ้างถึงจาก: EThaiZone ใน 18 กันยายน 2008, 17:24:18
ทุกอย่างมีทางเลือกเสมอ (ฮา)

<meta http-equiv="refresh" content="0;URL=3.php" />

:D :D

แล้วถ้าอย่างนี้หล่ะครับจะใช้ได้ทุก browser มั้ยครับ
(เท่าที่รู้คิดว่าไม่อะครับ  :o)

EThaiZone

ได้สิครับ ยกเว้น browser ไม่รองรับ html เลย

:P (โค้ดนี้สร้างจาก dreamweaver)

hikizume

ขอบคุณอีกครั้งนะครับคุณ EThaiZone ที่ช่วยตอบครับ
:)

chedsada

เข้ามางงครับ  ขอถามต่อละกัน

redirect เพื่ออะไรครับ แล้วทำไปทำไม
แล้ว  referer นี่ื่คืออะไร ทำไมต้องมี  referer ด้วย ถ้าไม่มีแล้วจะส่งผลยังไง

ในเมื่อเรามีเว็บของเราอยู่แล้วทำไมเราไม่ใช้เว็บเราเลยล่ะ  งงจริงๆครับ

ช่วยอธิบายให้กระจ่างทีครับ

EThaiZone

อ้างถึงจาก: chedsada ใน 18 กันยายน 2008, 18:38:22
เข้ามางงครับ  ขอถามต่อละกัน

redirect เพื่ออะไรครับ แล้วทำไปทำไม
แล้ว  referer นี่ื่คืออะไร ทำไมต้องมี  referer ด้วย ถ้าไม่มีแล้วจะส่งผลยังไง

ในเมื่อเรามีเว็บของเราอยู่แล้วทำไมเราไม่ใช้เว็บเราเลยล่ะ  งงจริงๆครับ

ช่วยอธิบายให้กระจ่างทีครับ
redirect ใช้ส่งต่อการแสดงผลไปยังหน้าอื่น อันนี้แล้วแต่กรณีคนทำว่าเขาใช้ทำเพื่ออะไีร

ส่วน referer เป็นค่าที่ตัว browser จะส่งไปยังเว็บ เพื่อบอกว่า
หน้านี้ หรือไฟลฺนี้ ได้มีการเข้ามาทางหน้าเว็บไหน
ซึ่งช่วยให้เราสามารถระบุที่มาต้นทางได้

รวมถึงใช้ป้องกันได้ เช่น การตรวจ referer เมื่อมีการเรียกรูปภาพเพื่อป้องกันการ hotlink

ูู^^"

Fly2BlueSky

อยากอิสระเหมือนนก ท่องไปไกลสุดขอบฟ้า จนสักวันได้เจอรักแท้ใต้แผ่นฟ้าเดียวกัน
~ Sanook Ka Travel ,Sabuy Ka Hotel , IN Travel Hotel ~

tinnoi

ขอบคุณมากครับ แต่มาขอถามเพิ่มนิดนึงตรง

<meta http-equiv="refresh" content="0;URL=3.php" />

แบบนี้ถือเป็น redirect แบบ 301 ไหมครับ
[direct=https://trainee.naruthee.com]หาที่ฝึกงาน[/direct] ,
[direct=http://www.piyamitrgroup.com]รับรื้อถอน[/direct] ,
[direct=https://fastvisa2024.weebly.com/]รับทำวีซ่า[/direct] ,
[direct=https://business.10thai.com]10thai[/direct]

Legendary Pon

อ้างถึงจาก: tinnoi ใน 23 กันยายน 2008, 19:42:20
ขอบคุณมากครับ แต่มาขอถามเพิ่มนิดนึงตรง

<meta http-equiv="refresh" content="0;URL=3.php" />

แบบนี้ถือเป็น redirect แบบ 301 ไหมครับ

ไม่ครับ

แล้วถ้าอยากรู้ว่าเพจไหน status เป็นอย่างไร เช็คด้วยเวบนี้นะครับ

[linkpr]http://www.seoconsultants.com/tools/headers.asp[/linkpr]
[direct=http://www.hostnog.com]เบื่อ Hostgator อยากใช้โฮสอื่นบ้าง ดู 10 โฮส คุณภาพดี เทียบเท่า Hostgator ราคาถูกกว่า ผมลองใช้เองมาแล้วทุกโฮส[/direct]
[direct=http://www.allofwedding.net]ผ้าแพร ผ้ารับไหว้ แต่งงาน[/direct] [direct=http://www.xn--t3cep2dyd1b.net]ผ้าแพร[/direct] [direct=http://www.xn--r3cdvrt8af1mqbh.com]ผ้ารับไหว้[/direct] [direct=http://www.bloggang.com/mainblog.php?id=legendary-pon]Legendary blog[/direct]

Backmoney

เกิดสงสัย ถ้าใช้ redirect ไม่ดีจะกลายเป็น Doorway ใช่ป่ะคับ

visavavit

301 redirect
อ้างถึงIIS Redirect

    * In internet services manager, right click on the file or folder you wish to redirect
    * Select the radio titled "a redirection to a URL".
    * Enter the redirection page
    * Check "The exact url entered above" and the "A permanent redirection for this resource"
    * Click on 'Apply'

ColdFusion Redirect
<.cfheader statuscode="301" statustext="Moved permanently">
<.cfheader name="Location" value="http://www.new-url.com">

PHP Redirect
<?
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: http://www.new-url.com" );
?>

ASP Redirect
<%@ Language=VBScript %>
<%
Response.Status="301 Moved Permanently"
Response.AddHeader "Location","http://www.new-url.com/"
%>

ASP .NET Redirect
<script runat="server">
private void Page_Load(object sender, System.EventArgs e)
{
Response.Status = "301 Moved Permanently";
Response.AddHeader("Location","http://www.new-url.com");
}
</script>

JSP (Java) Redirect
<%
response.setStatus(301);
response.setHeader( "Location", "http://www.new-url.com/" );
response.setHeader( "Connection", "close" );
%>

CGI PERL Redirect
$q = new CGI;
print $q->redirect("http://www.new-url.com/");

Ruby on Rails Redirect
def old_action
headers["Status"] = "301 Moved Permanently"
redirect_to "http://www.new-url.com/"
end

Redirect Old domain to New domain (htaccess redirect)

Create a .htaccess file with the below code, it will ensure that all your directories and pages of your old domain will get correctly redirected to your new domain.
The .htaccess file needs to be placed in the root directory of your old website (i.e the same directory where your index file is placed)

Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]

Please REPLACE www.newdomain.com in the above code with your actual domain name.

In addition to the redirect I would suggest that you contact every backlinking site to modify their backlink to point to your new website.

Note* This .htaccess method of redirection works ONLY on Linux servers having the Apache Mod-Rewrite moduled enabled.

Redirect to www (htaccess redirect)

Create a .htaccess file with the below code, it will ensure that all requests coming in to domain.com will get redirected to www.domain.com
The .htaccess file needs to be placed in the root directory of your old website (i.e the same directory where your index file is placed)

Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^domain.com [nc]
rewriterule ^(.*)$ http://www.domain.com/$1 [r=301,nc]

Please REPLACE domain.com and www.newdomain.com with your actual domain name.

Note* This .htaccess method of redirection works ONLY on Linux servers having the Apache Mod-Rewrite moduled enabled.
[direct=https://www.soomsiang.com/]แอปสุ่ม เว็บสุ่ม สุ่มชื่อ สุ่มร้านอาหาร เกมสุ่ม[/direct]