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.

1
  • What will aand b look like? Will a always be a number and b not? Commented Mar 28, 2015 at 21:33

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.