How can I hide URL parameters?

Hello guys. I have decided to hide the file extension in the URL for my website (in my case .php), this is already done. I do also want to hide all URL parameters. Why I want to hide all of this is because I find it more good looking/more professional looking. Hence I do NOT do it becasue if security reasons.

My question is, how can I hide the URL parameters without destroying the functionality of my website? The first thing that came to my mind was to save the parameter values in cookies instead. The problam that came up in my head straight away is that it would not work if the user has more than one of the same page open. Do you have any ideas?

Maybe I can somehow save the parameters in PHP sessions but I think that would cause the same problem as cookies would?

For clarification. 3 different parameters can be set on the pages. the url parameters values are changed upon a button click (onclick, not a form). so one of the buttons controls parameter number 1. another button controls parameter 2 and the last button controls the last parameter. The parameters get changed on page refresh.

Easiest way would probably be to use rewrite rules, how to set it up depends on your web server but it should be pretty straigt forward.

The simplest rule will allow you to access ie
yourpage.com/paramOne/paramTwo/paramThree

while your web server gets a request at
index.php?params=paramOne/paramTwo/paramThree

Which you can then use for whatever logic you’re after

1 Like

What Jim said. If you truly want to hide them, use post rather than get. To make it cleaned, use the pattern that JimL mentioned.

1 Like

Do you guys know how to do that with htaccess?
I cant get it to work. the htaccess file should be working correct tho
RewriteEngine on

RewriteRule ^test(.+)/?$ test?c=$1 [QSA,L]

RewriteRule /(.*)/$ test.php?c=$1

When you send the request, is it in that format, or are you expecting the htaccess file to change it?

1 Like

i thought the search engines could only snap it up if it is made with htaccess? I might be wrong

Common misunderstanding. Your URL should be something like

example.com/file/param

When it is received on the server, the htaccess file breaks that down so it knows how to route it based on the rules you specified. Here’s a bit more info on it, pretty urls explained

1 Like

oh so you mean it would be perfectly fine doing this directly to the buttonclick with window.location.href
I tried doing that but it gives me Internal Server Error

you do that for the url in conjugation with the htaccess file

1 Like
Sponsor our Newsletter | Privacy Policy | Terms of Service