I'm new to PHP. I was searching for a solution on the internet already but didn't find anything for my problem. I have a small list with links/bookmarks to external websites. I don't wan to link them directly. I want to create a redirect page.
B) My redirect.php file contains: ------------------------------------------ <?php if (isset ($_GET['URL']) && preg_match ('/^http:\/\/.+/i', $_GET['URL'])) header ("Location: " . $_GET['URL']); else // Alert if redirection failed. echo "Redirection failed!"; ?>
C) If I click on the link shown above the following error message appears: ------------------------------------------ Parse error: syntax error, unexpected T_STRING in /path_to_my_domain/redirect.php on line 3
I already checked the syntax but didn't find any errors which causes the message from above.
Any suggestions to solve the problem? Or do I have to choose another solution for my redirect problem?
The problem I do have is, I have to put the links in a list (<li>). I can't collect them in a pulldown menu. Is there another solution for redirecting pages?
I'm new to PHP. I was searching for a solution on the internet already but didn't find anything for my problem.
I have a small list with links/bookmarks to external websites. I don't wan to link them directly. I want to create a redirect page.
A) My links are shown like that:
------------------------------------------
<li>http://www.mydomain.com/redirect.php?URL=http://www.externalsite.com</li>
<li>http://www.mydomain.com/redirect.php?URL=http://www.externalsite2.com</li>
<li>http://www.mydomain.com/redirect.php?URL=http://www.externalsite3.com</li>
etc.
B) My redirect.php file contains:
------------------------------------------
<?php
if (isset ($_GET['URL']) && preg_match ('/^http:\/\/.+/i', $_GET['URL']))
header ("Location: " . $_GET['URL']);
else
// Alert if redirection failed.
echo "Redirection failed!";
?>
C) If I click on the link shown above the following error message appears:
------------------------------------------
Parse error: syntax error, unexpected T_STRING in /path_to_my_domain/redirect.php on line 3
I already checked the syntax but didn't find any errors which causes the message from above.
Any suggestions to solve the problem? Or do I have to choose another solution for my redirect problem?
Thanks a lot,
Michael
So if you you just a URL inside <li> tags and then attempt to grab that, it won't work.
Your HTML form:
Your redirect.php page
The problem I do have is, I have to put the links in a list (<li>). I can't collect them in a pulldown menu.
Is there another solution for redirecting pages?
M.
1. Create a page redirect.php:
<?php
$url = $_GET['url'];
header("Location: $url");
?>
2. Create a robots.txt file and write:
Disallow: /redirect.php?*
3.
In the page where you list all of the links you, write the following code:
<li>http://www.yourownpage.com/redirect.php?url=http://www.externallink1.com</li>
<li>http://www.yourownpage.com/redirect.php?url=http://www.externallink2.com</li>
<li>http://www.yourownpage.com/redirect.php?url=http://www.externallink3.com</li>
4. That's all!