ERROR: HTTP/1.1 301 Moved Permanently Location

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
UniqueIdeaMan
Forum Contributor
Posts: 197
Joined: Wed Jan 18, 2017 3:43 pm

ERROR: HTTP/1.1 301 Moved Permanently Location

Post by UniqueIdeaMan »

Hard Men, :D

Check this weird thing out!
Fire-up your Wamp/Xampp and try this code:

Code: Select all

<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://ebay.com");
curl_setopt($ch, CURLOPT_HEADER, 5);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$result = curl_exec($ch);
curl_close($ch);
$result = preg_replace("#(<\s*a\s+[^>]*href\s*=\s*[\"'])(?!http)([^\"'>]+)([\"'>]+)#",'$1http://mydomain.com/$2$3', $result);
echo $result
?>
Now, instead of ebay.com loading you will see an error mssg like so:

HTTP/1.1 301 Moved Permanently Location: http://www.ebay.com/

What does that mean ? On my Chrome, I don't see ebay.com showing any likewise mssg. Nor, am I getting redirected to any other page.

I found the code here:
https://stackoverflow.com/questions/105 ... urled-html

It is supposed to replace all relative links to absolute links.

Enjoy!
Post Reply