简体   繁体   中英

Want .htaccess to display name instead of id?

I am working on site in which their are user profiles, now I want to display the profiles names or say username through .htaccess. For example: my site have a profile of one user the link is given

http://websoftnet.com/projects/uklasertherapy/?page_id=62&th_id=3

and I want .htaccess to display this

http://websoftnet.com/projects/uklasertherapy/profile/saeed

How can I do this through .htaccess?

The technique is called URL Rewriting. Check this sites out:

  1. URL Rewriting Guide (Apache)
  2. URL Rewriting (Your HTML Source)

Warning: Untested code

You need to have a .htaccess file along the lines of

RewriteEngine on
RewriteRule ^projects/uklasertherapy/profile/([a-zA-Z])/$ projects/uklasertherapy/profile.php?name=$1

Where profile.php would take the variable name from the GET parameter and get the page for the user with that name.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM