简体   繁体   中英

User friendly URL's for profiles

I have the following link:

www.website.com/profile.php?user=Test

I want to change the link to be:

www.website.com/Test

Where the username is after the / without any extra gibberish.

I have this set up in my .htaccess file, but it's not working. Why?

Options +SymLinksIfOwnerMatch
RewriteEngine on

RewriteBase /website

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)$ profile.php?user=$1 [R,L,QSA]

Thanks.

Try this

Options +SymLinksIfOwnerMatch
RewriteEngine on

RewriteBase /website

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)$ profile.php?user=$1 [L,QSA]

Now you can access page from this URL.

www.website.com/Test

Try to add the following:

Options +FollowSymLinks
RewriteEngine On
RewriteRule  Test$ /profile.php?user=Test [QSA,L]
RewriteRule ^/(.*)$ /profile.php?user=$1 [QSA,L]

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