Is it possible to rewrite htaccess rule so if you are on /profile?id=2
you will only see /profile
?
When I was looking for solutions I only found how to make it be /profile/2
.
Is it possible to rewrite htaccess rule so if you are on /profile?id=2
you will only see /profile
?
When I was looking for solutions I only found how to make it be /profile/2
.
.htaccess allows redirects. It takes the address you asked for, and routes that to a specific place. It doesn't make the user see something different from the page they're on.
So in those solutions, you are on /profile/2. And that gets routed to /profile?id=2. It's not a case of being on one but being shown the other.
So if you're on /profile, sure you can route that to /profile?id=2 no problem. But what if your id was really 3? If you don't have that in the url you enter, .htaccess has no way to know.
More likely you would use a cookie or session variable to keep track of the user's id. Then when the visit /profile you get their id from the session not the url.