Hy guys, I want to make a redirect.php page. I want to make it like this : redirect.php?url=http://site.com So when you enter that url it redirects to http://site.com What's the piece of code to use ? I tried this but it's not working : <?php header("Location: $_GET['$url']"); ?> PHP: Can you help me please ? Thanks
Nope, not working, I asked a friend he gave me the code, and it's working : <?php $u=$_GET['url']; echo " <script>window.location='".$u."'</script> "; ?> PHP: Thanks anyways for your time rep added
<?php header("Location: $_GET['$url']"); ?> PHP: doesn't work because you have an array in the double quoted string: normal variables can be done like that, but not array items (reliably). <?php header( 'Location: $url' ) ; ?> PHP: won't work because you have a variable in a single quoted string: single quoted strings aren't parsed for variables. What you were looking for, really, is something like: <?php header('Location: ' . $_GET['$url']); ?> PHP: Hope that helps for the future...
God, got to say...NOOBS. Anyway: <?PHP die(header("location: ".$_GET['url'])); ?> There...That will work, enjoy!
The reason this isn't working for you is because you're using a variable (or trying to) inside the GET. $_GET["$url"] will never work. It has to be $_GET["url"].
Ah crap, my bad... absolutely right guys. Sorry, just a little too much copy and pasting on my behalf...
<?php header('Location: '.$_GET['url']); die('Go to '.$_GET['url']); ?> PHP: Why was this thread SO long? , I would've made it a hyperlink but I'm lazy.