0

Currently on my website, my profile urls look like this: ../user/?id=1

I would rather them look like this: ../user/1

How would I go about this? I'm running this with Apache and PHP if that is important to the question.

  • Check this out: https://stackoverflow.com/questions/41263261/get-id-from-url-in-a-variable-php – user1392897 Jan 10 '21 at 05:59
  • Does this answer your question? [Get id from url in a variable PHP](https://stackoverflow.com/questions/41263261/get-id-from-url-in-a-variable-php) – Sinh Nguyen Jan 10 '21 at 10:59

1 Answers1

0

You can do this with .htaccess Example:

<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On

RewriteRule ^user/([a-zA-Z0-9_-]+)$ user.php?id=$1 [L,QSA]

</IfModule>

This htaccess rule will redirect input like www.site.com/user/123 to user.php?id=123

mrSotirow
  • 103
  • 1
  • 4