是可以重定向到一個文件,然後2次,第三次將其重定向到別的地方重定向文件只有一次
EX:的index.php重定向到/index2.php然後/index2.php重定向到/index.php ..... ,,,,然後第二次訪問/index.php它會將我們重定向到其他文件?
我們可以用javascript或PHP來做到這一點嗎?
是可以重定向到一個文件,然後2次,第三次將其重定向到別的地方重定向文件只有一次
EX:的index.php重定向到/index2.php然後/index2.php重定向到/index.php ..... ,,,,然後第二次訪問/index.php它會將我們重定向到其他文件?
我們可以用javascript或PHP來做到這一點嗎?
的index.php redirets到index2.php
index2.php重定向到的index.php?r=1
中的index.php檢查:
if($_GET['r']==1){
//redirect to other page
}
UPDATE
我瞭解你有這樣的重定向:
1. Somewhere => index.php
2. index.php => site.com
3. site.com => index.php // and in this step you need to redirect to other place
所以只需添加檢查:
<script type="text/javascript">
if(document.referrer == 'site.com'){
location.href = 'OTHER PAGE ADDRESS';
}
else{
location.href = 'site.com';
}
</script>
所以,如果用戶從其他網站來了,他會重定向到site.com如果他從網站。 com何時去其他地方。
是的,您可以在會話變量中添加一個計數器來跟蹤重定向。每次重定向後,遞增計數器。
當計數器達到其極限時,執行所需的操作。
是的,你可以。問題是你想要它是多久。
JAVASCRIPT:
如果你想用JavaScript來做到這一點,然後看看 window.location
並記住用戶是否在第一頁上只使用JavaScript的cookie。 簡單教程http://www.tutorialspoint.com/javascript/javascript_cookies.htm 您也可以設置到期。
PHP:
如果你想讓它「少永久」,例如剛一個打開瀏覽器窗口或類似的,然後看看PHP會話管理的東西 http://php.net/manual/en/features.sessions.php
謝謝,但對於像我這樣的新手來說太複雜了:P – cton453 2013-03-20 12:05:56
對不起,我想我問錯了問題我只有超過1個重定向控制,所以我只能控制1個文件EX:HTTP://site.com/redirect1重定向到mysite的/索引.php然後mysite/index.php重定向到site.com/redirect1所以現在我使用javascript重定向setInterval(function(){document.location =「site。com/redirect1「},3500);但是這最終會像一個輪子裏的松鼠:P – cton453 2013-03-20 12:03:55
在這種情況下,您可以使用'document.referrer'並檢查它是否從site.com重定向到不同的地方 – Narek 2013-03-20 12:11:57
這將如何工作我有什麼可以使用的櫃檯? – cton453 2013-03-20 12:28:31