I have a page which currently displays user information based on values passed through $_GET['username']
What I currently have Is when a user goes to url.com/user/index?username=username
(for example) it will display username's page. If the variable is not set however like url.com/user/index
, it will display the logged in users page instead.
It works, however, that Is not what I want. How I would like it to work is; if the user goes to url.com/user/exampleuser
it will display exampleuser's page and If they go to url.com/user/
it just displays the logged in user.
I am currently testing on an xampp server (localhost) and I can't seem to find anything which works how I would like it to.
Any and all help is appreciated!
EDIT
this is my new .htaccess:
Options -Indexes
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
RewriteRule ^user/([A-Za-z0-9-]+)$ user/index?username=$1;
however, when I go to the page ie localhost/test/user/username
it gives me object not found!
error
RewriteEngine On
RewriteRule ^user/([A-Za-z0-9-]+)$ user/index?username=$1;
# for particular user details
RewriteRule ^user/$ user/index; # for all logged in user list
For Eg. your url is user/index?username=testuser
after rewrite apply it look like user/testuser
it is for particular user details for all user list you just use user/
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.