Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/87.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何重定向多个链接_Php_Html_Redirect - Fatal编程技术网

Php 如何重定向多个链接

Php 如何重定向多个链接,php,html,redirect,Php,Html,Redirect,我需要将一些html页面重定向到相应的php页面 这意味着,如果用户来自任何引用我的www.example.com/sample.html页面的站点,他应该被重定向到www.example.com/sample.php页面,而不显示html页面 我需要这样做3页。我该怎么做?请帮助我:)您可以创建一个.htaccess文件,并将其放在web服务器的根目录中。它应包含以下内容: Redirect 301 /sample1.html http://www.example.com/sample1.ph

我需要将一些html页面重定向到相应的php页面

这意味着,如果用户来自任何引用我的www.example.com/sample.html页面的站点,他应该被重定向到www.example.com/sample.php页面,而不显示html页面


我需要这样做3页。我该怎么做?请帮助我:)

您可以创建一个
.htaccess
文件,并将其放在web服务器的根目录中。它应包含以下内容:

Redirect 301 /sample1.html http://www.example.com/sample1.php
Redirect 301 /sample2.html http://www.example.com/sample2.php
Redirect 301 /sample3.html http://www.example.com/sample3.php

您可以创建一个
.htaccess
文件,并将其放在web服务器的根目录中。它应包含以下内容:

Redirect 301 /sample1.html http://www.example.com/sample1.php
Redirect 301 /sample2.html http://www.example.com/sample2.php
Redirect 301 /sample3.html http://www.example.com/sample3.php
试试这个

<?php
header('Location: www.example.com/sample.php');
?>

试试这个

<?php
header('Location: www.example.com/sample.php');
?>

您可以使用.htaccess文件正确重定向文件

在.htaccess中包含cose

重新启动发动机 重写规则^(.*).html$$1.php

或者以其他方式

像php一样使用

echo“window.location='\www.example.com/sample.php'\”


希望我能以更好的方式帮助您

您可以使用.htaccess文件正确重定向您的文件

在.htaccess中包含cose

重新启动发动机 重写规则^(.*).html$$1.php

或者以其他方式

像php一样使用

echo“window.location='\www.example.com/sample.php'\”


希望我能通过以下行更好地帮助您创建.htaccess:


使用以下行重定向301^(.*.html$$1.php

Create.htaccess:


重定向301^(.*.html$$1.php

我应该将此文件放在哪个根目录下?放在承载要重定向的.html文件的站点的根目录下。我应该将此文件放在哪个根目录下?放在承载要重定向的.html文件的站点的根目录下。我需要为.html文件执行此操作:(在html文件中添加这一行。它将在1秒后重定向页面。我不想在那里显示.html页面,然后重定向。是否有通过.htaccess的选项。我需要为.html文件执行此操作:(在html文件中添加这一行。它将在1秒后重定向页面。我不想在那里显示.html页面,然后重定向。是否可以通过重写规则^(.*)上的.htaccessRewriteEngine进行任何选项).html$$1.phpOf当然,只有当html页面和php页面的名称相同时,这才有效。为了降低延迟和搜索引擎,我更喜欢RewriteRule^(.*)上的“重定向301^(.*).html$$1.php”RewriteEngine.html$$1.phpOf当然,只有当html页面和php页面的名称相同时,这才有效。为了降低延迟和搜索引擎,这是一个优雅的解决方案,我更喜欢“重定向301^(.*).html$$1.php”