简单页转到?转到、简单

2023-09-02 09:38:27 作者:不离不弃童言无忌i,

我有一个页面 http://site.com/services/ ,我只是想重定向它 http://site.com/servics/first-service/

I have a page at http://site.com/services/ and I just want to redirect it to http://site.com/servics/first-service/

最新最好的重定向做到这一点,我怎么做到这一点?

Whats the best redirect to do this and how do I do this?

推荐答案

PHP

header("Location: yourpage.php");
exit;

您必须使用退出模具以停止执行你的code。 此外,code有任何输出之前执行。

You have to use exit or die after header in order to stop execution of your code. Also, the code has to be executed before any output.

HTML

<meta http-equiv="refresh" content="0;url=yourpage.php">

在code之间应&LT; HEAD&GT;&LT; /头&GT; 标签

的JavaScript

window.location = "yourpage.php";

的.htaccess

.htaccess:

Redirect 301 /oldpage.php /newpage.php
 
精彩推荐
图片推荐