配置文件的用户友好 URL


User friendly URL's for profiles

我有以下链接:

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

我想将链接更改为:

www.website.com/Test

用户名在/之后,没有任何额外的乱码。

我在我的 .htaccess 文件中设置了这个,但它不起作用。为什么?

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]

谢谢。

试试这个

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]

现在,您可以从此URL访问页面。

www.website.com/Test

尝试添加以下内容:

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