带有动态细分的重定向页面[关闭]

How to redirect from one page to another? Oh and my segments are dynamic, so it will change.

Is this possible?

Example.

www.test.com/oldtest/hello

to

www.test.com/newtest/hello

OR

www.test.com/oldtest/hellobaby

to

www.test.com/newtest/hellobaby

Set a redirect to the new URL and use your segment as a variable.

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

Try this:

There are 2 methods to do this.

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>

write your htaccess file:

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]