2

Is there any way I can remove the question mark from URL? Now lets say that the URL can be http://www.domain.com/profile?a=10 but it can also be http://www.domain.com/profile?b=ticket.

So in the first case my URL should be http://www.domain.com/profile/10 and in the second http://www.domain.com/profile/ticket.

But I still want to be able to use $_GET in PHP. So what I really want is to remove the question mark only to the user, but in the server it should work the same. Is there any way I can do this, probably using htaccess. I am running apache2 as my webserver on Ubuntu 14.10.

Idrizi.A
  • 9,819
  • 11
  • 47
  • 88

1 Answers1

2

Yes you can do it with .htaccess

<IfModule mod_rewrite.c>
  RewriteCond %{REQUEST_FILENAME} !-d 
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^profile/([^.]*)$ profile.php?a=$1&b=$1 [QSA,L]
</IfModule>

where profile.php will be your PHP code that handles both the cases.

Gopakumar Gopalan
  • 1,187
  • 14
  • 22