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

215
Views
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 answers
Answer question

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 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!