Question

Please open the following two links or any other page for a question on stackoverflow and remove the last parameter i.e. question separated by '-' and open it.

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

each time stackoverflow shows the complete URL.

How to implement this feature for a PHP based web application?

Était-ce utile?

La solution

When you look at the HTTP response headers (e.g. by using curl -D - http://... on the console), you'll see that SO answers with:

HTTP/1.1 301 Moved Permanently

So it's an HTTP redirection.

In regards to search engines like Google it can be important in order to prevent duplicate content.

For PHP have a look at header(): http://www.php.net/manual/en/function.header.php

Use:

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

If you only issue header("Location: ..."); PHP will send a 302 redirect.

Side note: According to this QA SO didn't do this back in 2010.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top