Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

224
Vistas
Simple Page Redirect Using URL

I want my index.php to redirect to my welcome/index.html. I know there are so many ways to do it but I want to shorten it just like Facebook does. I want a url based redirection. I want to redirect index.php to welcome/index.html by using url.

For example:

example.com to example.com/?url=welcome
//this 'url=welcome' is the index.html of my welcome folder.
about 4 years ago · Santiago Trujillo
3 Respuestas
Responde la pregunta

0

Here's the code, according to what I've understood. Place it on the very top of index.php. I'm assuming you're using the domain example.com

<?php 

$destination = $_GET["url"];

switch($destination) {
    case "welcome": // add your destinations here, one per single "case"
    case "about":
    case "anotherpage":
        header("Location: /" . $destination . "/index.html");
    break;   
    default:
        echo "Error";
    break;
}

?>

Doing this way you can manage which redirects will work and what not, avoinding "evil" usages of your redirect system.

Something malicious like example.com?url=http://evilsite.com will not redirect them to evilsite.com

This is probably not the best solution, but it's a good starting point to avoid not wanted redirections.

about 4 years ago · Santiago Trujillo Denunciar

0

Not really sure if this would help, but you're welcome to try

<?php 
  if (isset($_GET["url"])) {
    $url = $_GET['url'];
    header('Location:'.$url);
  }
 ?>

I haven't tried this, but this is what I thought after seeing your post

about 4 years ago · Santiago Trujillo Denunciar

0

somewhere i read using header for redirection is little bit dangerous as header can b changed easily by hacker and hacker can send victim to another location easily. so i use javascript location.href function for redirection.

<?php
echo "<script>window.location ='http://example.com/welcome/index.html</script>";
?>

if you want to send user to dynamic url from example.com you can set a get variable like.

source address: http//example.com?url=http://example.com/welcome.html destination address: http://example.com/welcome.html

<?php
if(isset($_GET['url']))
echo "<script>window.location ='$_GET[url]'</script>";
else
echo "<script>window.location='http://somewhereelse.com'";
?>

now u can dynamically set url variable in your source address and redirect user wherever you want to

about 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda