First, remember to put this line in your .htaccess
before any rewrites:
RewriteEngine on
If you want site.com/something
to display site.com/something.php
if it exists without changing the URL, do this:
RewriteCond %{REQUEST_URI}.php -f
RewriteRule .* %{REQUEST_URI}.php
That will display a [file you requested].php if it exists while still showing the same URL you entered. If the php file doesn't exist, it will still give you a 404 as it should. (That's what the -f
is for.)
There is no way to hide the GET requests completely. You can get rid of the GET requests, but then they won't be available to your script either and there's no point. You can, however, make it look nicer. For example, if you want site.com/userpage/item/30
to display the content of site.com/userpage.php?item=30
, you can do something like this:
RewriteRule ^/userpage/item/(.*)$ userpage.php?item=$1
You could also make it work with any GET value with a rule like this:
RewriteRule ^/userpage/(.*)/(.*)$ userpage.php?$1=$2
With that in effect, you could access site.com/userpage.php?query=yes
with site.com/userpage/query/yes
instead. That's pretty much the best you can do; GET values have to come from the URL somehow, so if you want your inputs completely hidden you'll have to use POST instead.