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

216
Visualizações
Remove question mark from query string using .htaccesss

What I have in my URL is https://www.example.com/?id=987456 I can display all the user data fetched from database using the $id = $_GET['id'];

Now I want to remove just the ?id= so the URL will good.

The required URL will looks like https://www.example.com/987456

NB. I have a lot of other files, folder and subfolders in that same domain so these docs must not affected.

I have to get 987456 value so I can display the user content based on that.

Its better if it can work with .htaccess I'm using LiteSpeed Web Server with PHP 7.4 version Just I don't want the user to see this ?id=

How can I achieve this idea.

Please help me?

Thank you for your help in advance.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Two completely different things need to happen. First, you need to externally redirect the browser to show something different in the URL address bar. Second, when the browser resends the 2nd request, the server internally rewrites the query string back. You can't arbitrarily add or remove things in URLs in the wild, as they are locators. You can create a new locator, tell the browser to use this new one instead of the old one, then internally on the server change the new one back to the old one.

See the top part of this answer for an explanation

To make the browser go to the new URL:

RewriteEngine On
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(index\.php)?\?([^&\ ]+)
RewriteRule ^ /%1? [L,R=301]

This takes a request for the URL: http://example.com/?something and redirects the browser to the URL: http://example.com/something

Then you need to internally rewrite it back:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?$1 [L]

When the request is made for http://example.com/something, the server rewrites the URI to /index.php?something. This is internal to the server so the browser knows nothing about it and will continue to display the URL http://example.com/something while the server processes the URI /index.php?something.

about 4 years ago · Juan Pablo Isaza Relatório
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