Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

132
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda