如何從一個頁面重定向到另一個頁面?哦,我的部分是動態的,所以它會改變。帶動態段的重定向頁面
這可能嗎?
例子。
www.test.com/oldtest/hello
到
www.test.com/newtest/hello
OR
www.test.com/oldtest/hellobaby
到
www.test.com/newtest/hellobaby
如何從一個頁面重定向到另一個頁面?哦,我的部分是動態的,所以它會改變。帶動態段的重定向頁面
這可能嗎?
例子。
www.test.com/oldtest/hello
到
www.test.com/newtest/hello
OR
www.test.com/oldtest/hellobaby
到
www.test.com/newtest/hellobaby
設置重定向到新的網址,並使用你的段作爲變量。
<?php header("Location: www.test.com/newtest/" . $sSegment); ?>
太簡單了,謝謝:)我會接受你的回答:) – Zaz
試試這個:
有兩種方法來做到這一點。
1. Using PHP
<?php header("Location: www.test.com/newtest/hellobaby"); ?>
Use this as a first line in the page.
2. Using javascript
<script type="text/javascript">
window.location.href = "www.test.com/newtest/hellobaby";
</script>
寫你的htaccess文件:
Options +FollowSymLinks
RewriteEngine On
RewriteBase/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^/oldtest/hello [NC]
RewriteRule .* /newtest/hello [R=301,L]
你能告訴你如何做,現在一些代碼? – putvande