Jump to content

[SOLVED] Parse URL and Redirect


phpretard

Recommended Posts

I am trying to simulate a default 404 for all sites on my server.

 

I need to parse the referring page and redirect to the home page of the applicable site.

 

Here's what I have so far...

 

<?php

$url=$_SERVER['HTTP_REFERER'];

//$url = 'https://www.dontmatter.com/index.php?limitstart=3 '; // this was for testing

print_r(parse_url($url));

echo parse_url($url, PHP_URL_PATH);

$404F=$???; // I am trying to get the [host] value from this array and put it in a var.

header( "Location: $404F" ) ;
?> 

 

Thank you

 

PS. this is just a band aid until I figure out Plesk

Link to comment
Share on other sites

<?php $url=array("scheme"=>array("host"=>"www.dontmatter.com")
,"path"=>array("/index.php"),"query"=>array("limitstart=3")); ?>

This is not, what parse_url returns.

 

It returns a (one-dimensional) associative.

"scheme" is the key, which contains the protocol(eg.g http, https), it is not an array

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.