For example, let's say my website is www.mywebsite.com/profile.php?id=1. My account is 1, but instead of having that /profile.php?id=1, I want to instead to be able to give a link to my friends that is my name instead, so it ends up being www.mywebsite.com/chrisgreene.
I was looking into Apache's URL rewrite, but I didn't know if that was something that converted it after the fact (just a 'cover up' to show as you went to the page), rather than a hard link to use to get to the same page.
Visit http://roshanbh.com.np/2008/03/url-rewriting-examples-htaccess.html
Maybe can be useful for you.
in a .htaccess file in the root of your web dir. you add this:
RewriteEngine on
RewriteRule ^([a-z]+)$ profile.php?name=$1
then on your profile page get the results based on the name.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ profile.php?name=$1 [NC,L]
Now you will get the name within your profile.php you have to search the name withing your db and use that's id.
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.