Php 使用动态段重定向页面

Php 使用动态段重定向页面,php,html,redirect,Php,Html,Redirect,如何从一个页面重定向到另一个页面?哦,我的片段是动态的,所以它会改变 这可能吗 例如 www.test.com/oldtest/hello 到 或 到 设置重定向到新URL并将您的段用作变量 <?php header("Location: www.test.com/newtest/" . $sSegment); ?> 试试这个: 有两种方法可以做到这一点 1. Using PHP <?php header("Location: www.test.com/newte

如何从一个页面重定向到另一个页面?哦,我的片段是动态的,所以它会改变

这可能吗

例如

www.test.com/oldtest/hello


设置重定向到新URL并将您的段用作变量

<?php header("Location: www.test.com/newtest/" . $sSegment); ?>
试试这个:

有两种方法可以做到这一点

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]

你能告诉我你现在是怎么做的吗?很简单,谢谢:我接受你的回答:
<?php header("Location: www.test.com/newtest/" . $sSegment); ?>
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>
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]