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

119
Vistas
htaccess rewrite fake directories to GET parameters in PHP

My htaccess file is

RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]

RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f

RewriteRule ^news/(.*)$ index.php?news=$1 [QSA]

so if I goto https://example.com/news/2022-04-01 it should really goto https://example.com?news=2022-04-01 and according to htaccess.madewithlove.com that it what it evaluates to. However, the PHP (index.php in this case), still sees it as /news/2022-04-01 and the $_GET array is empty. Am I missing something really obvious since the whole point of the rewrite is to change it to a GET parameter before it hits my PHP file. Putting this at the start of my PHP file

<?php
echo "https://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]<br/>";
print_r($_GET);
die();

shows array() if I pass it as a directory (which shows it does just goto index.php) but array('news'=>'2022-04-01') if I do it as 'normal' parameter passing. So, can it be done in PHP (or JQuery/Javascript).. And if it can be done, please don't hardcode 'news', there are 8 different possibilities being passed so I need a generic routine. Many thanks Adrian

about 4 years ago · Santiago Trujillo
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