Membership is FREE – with unlimited access to all features, tools, and discussions. Premium accounts get benefits like banner ads and newsletter exposure. ✅ Signature links are now free for all. 🚫 No AI-generated (LLM) posts allowed. Share your own thoughts and experience — accounts may be terminated for violations.

php full retard

Status
Not open for further replies.
Joined
Aug 25, 2007
Posts
2,235
Reaction score
41
Trying to create a simple script that redirects a 404 error to another page,
hoping someone can tell me why this does not append the variable to url.. gunna kick myself i know (don't say i need to do something in .htaccess)

Code:
<?

/* Redirect to a different page than that was requested */

$userstypo = explode('/', parse_url($userstypo, PHP_URL_PATH));

$userstypo = end($userstypo);

$host  = $_SERVER['HTTP_HOST'];

$uri   = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');

$extra = 'some-dir';

header("Location: http://$host$uri/$extra/$userstypo");
exit;
?>

want to send them to: domain.com/dir/$userstypo if they go domain.com/$userstypo if that makes sense.

Apologies for me shite php...

ta.
 
Have you tried to echo $userstypo - to see if that has what you want in it?
 
Im not on the main PC yet so cant see but is the PHP_URL_PATH calling the path of your 404 file. if your server has automatically redirected to 404.php
see if you can pull the referring url.
Also try echoing the header url to see what its building might be stuck in a loop
 
Status
Not open for further replies.
General chit-chat
Help Users
  • No one is chatting at the moment.
      Helmuts @ HelmutsHelmuts is verified member.: Good morning all
      Top Bottom