I am using xamp to host my webpage on my PC and I want to change this url from
http://localhost/loginsystem/profile.php?user=myUsername
to
http://localhost/loginsystem/profile/myUsername
I have tried the following and doesn’t work and in return gives server error 500.
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^/profile/([a-zA-Z0-9]+) /profile.php?user=$1 [NC, L]
and
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^/profile/(.*)?$ /profile.php?user=$1 [NC, L]
Any help would be great still pretty new. Thanks in advance!
2
Answers
This should do the trick
Also make sure that your .htaccess file is in the loginsystem folder. Otherwise you will need to put this in your rewrite rule
Replace .htaccess code with:
Now you can get user query with GET request.