Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

141
Views
Redirigir la URL de una página web a otro sitio web

Tengo un sitio web PHP simple. Llamémoslo youtubex.com . Quiero redirigir las URL de youtubex (en el formato que se muestra en el PASO 2) a mi sitio web en el formato que se muestra en el PASO 3. Aquí, estoy usando YouTube, solo como ilustración.

 STEP1: https://www.youtube.com/watch?v=lj62iuaKAhU STEP2: https://www.youtubex.com/watch?v=lj62iuaKAhU STEP3: https://www.youtubex.com/#url=https://www.youtube.com/watch?v=lj62iuaKAhU

STEP1 muestra cualquier URL deseada. El PASO 2 muestra la misma URL del PASO 1 con youtubex como dominio. El PASO 3 muestra la URL requerida final. Estoy tratando de redirigir STEP2 a STEP3.

Intenté encontrar algunas soluciones para esto en Internet y SO, pero ninguna ayuda. Aquí hay uno .

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

Esto debería hacer el trabajo:

 RedirectMatch 301 /watch$ https://www.youtubex.com/#url=https://www.youtube.com/watch
over 4 years ago · Santiago Trujillo Report

0

Una solución php ineficiente pero completa puede ser usar el encabezado de ubicación en php:

 $vid = $_GET['v'] if($vid){ header("location:https://www.youtubex.com/#url=https://www.youtube.com/watch?v=$vid"); }

por cierto, no puede obtener el texto después de la marca hash en php porque no se envía al servidor.

javascript puede hacerlo de una manera más ordenada sin la segunda recarga al verificar window.location.href para ver si el hash aún no existe y luego obtener el parámetro v en url y luego cambiar la url sin actualizar la página usando window.history.pushState({"html":response.html,"pageTitle":response.pageTitle},"", urlPath);

over 4 years ago · Santiago Trujillo Report

0

usando php str_replace y encabezado:

 $step2_url = "https://www.youtubex.com/watch?v=lj62iuaKAhU"; $part2_url = str_replace("youtubex","youtube",$step2_url);//the output is : https://www.youtube.com/watch?v=lj62iuaKAhU $step3_url = "https://www.youtubex.com/#url=".$part2_url; //the output is : https://www.youtubex.com/#url=https://www.youtube.com/watch?v=lj62iuaKAhU

ahora que tiene la url final, simplemente redirija

 header($step3_url);
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!