0

This might be a duplicate, but I am having difficulties in finding a proper solution to solve my problem. I would like to accomplish the following:

STEP 1: Hide PHP extension for all my pages. And I managed to do that by having:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php [NC,L]

STEP 2: Hide query string, meaning variables passed from another page. And this is the part I am missing.

From index I pass the following link:

setup?id=123

In my setup page, I do the $_GET['id'] to read the id attribute.

URL shows it as

http://subdomain.localhost:777/setup?id=123

So, everything works as expected.

My question now is how do I rework my httaccess so that it hides the ?id=123 part and shows it as:

http://subdomain.localhost:777/setup

Any help or guidance is highly appreciated.

IMSoP
  • 89,526
  • 13
  • 117
  • 169
trinula
  • 1
  • 3
  • [Rewrite rules don't make ugly URLs pretty, they make pretty URLs ugly](https://stackoverflow.com/a/67254596/157957). If the pretty URL doesn't have "123" in it anywhere, there's no way to magically add it to the resulting ugly URL. – IMSoP Sep 23 '21 at 12:59
  • I think that you won't get $_GET['id'] anymore after such rewrite. Only solution is to save it in a session and then redirect to url without get parameters by php. – Robert Sep 23 '21 at 13:01
  • Thanks a lot @IMSoP and @Robert! I think I got it now. :-) – trinula Sep 23 '21 at 15:21

0 Answers0