-1

I'm creating a system which shows your profile if you visit http://example.com/profile/profile.php?username=test

I would like to make it so you could go to http://example.com/profile/test and it would still work. At the same time I would like it to show ^^ as the url if you visit http://example.com/profile/profile.php?username=test

How can this be done?

  • 4
    Does this answer your question? [How to create friendly URL in php?](https://stackoverflow.com/questions/812571/how-to-create-friendly-url-in-php) – CD001 Apr 07 '20 at 08:42

1 Answers1

0

This should do :

RewriteEngine on
RewriteRule ^profile/(.*)$ http://example.com/profile/profile.php?username=$1 [L]

You want to match everything after profile/ to the end of URI, and then pass it as parameter value to your "real" URI.

[L] flag may not be necessary, it indicates the rewrite engine you're done and it does not have to go throught the next rules.

You can try it here

Edit : I just see @Peter's comment, you definitively should read the question he linked, it will help you understand the whole thing.

Will
  • 899
  • 8
  • 15