Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/297.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 URL重写还是重定向?_Php_.htaccess - Fatal编程技术网

Php URL重写还是重定向?

Php URL重写还是重定向?,php,.htaccess,Php,.htaccess,对于stackoverflow问题,请打开以下两个链接或任何其他页面,删除最后一个参数,即以“-”分隔的问题,然后打开它 http://stackoverflow.com/questions/3478482/how-to-add-real-time-data-in-a-dual-y-axis-zedgraph-graph-using-c http://stackoverflow.com/questions/3478482/how-to-add http://stackoverflow.com/

对于stackoverflow问题,请打开以下两个链接或任何其他页面,删除最后一个参数,即以“-”分隔的问题,然后打开它

http://stackoverflow.com/questions/3478482/how-to-add-real-time-data-in-a-dual-y-axis-zedgraph-graph-using-c http://stackoverflow.com/questions/3478482/how-to-add http://stackoverflow.com/questions/3478482/how-to-add-real-time-data-in-a-dual-y-axis-zedgraph-graph-using-c http://stackoverflow.com/questions/3478482/how-to-add 每次stackoverflow都会显示完整的URL


如何为基于PHP的web应用程序实现此功能?

查看HTTP响应头时(例如,使用
curl-D-http://...
在控制台上),您将看到SO的回答如下:

HTTP/1.1 301 Moved Permanently
所以这是一个HTTP重定向

对于像谷歌这样的搜索引擎来说,为了防止重复内容,这一点很重要

对于PHP,请查看header():

使用:

如果您只发布
标题(“位置:…”PHP将发送302重定向

旁注:根据SO的说法,2010年没有这样做

header("HTTP/1.1 301 Moved Permanently");
header("Location: http://www.New-Website.com");