我无法使用干净的用户个人资料网址。我已经尝试了一切!我想重定向
http://localhost/test/profile?username=gadgetster
至
http://localhost/test/profile/gadgetster
这是我的尝试:
Options -Indexes -MultiViews +FollowSymlinks
RewriteEngine On
RewriteBase /test/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_URI}\.php -f [NC]
RewriteRule ^(.+?)/?$ $1.php [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^profile/(.+)$ profile.php?username=$1 [L,NC,QSA]
为什么这不起作用?
像这样:
Options -Indexes -MultiViews +FollowSymlinks
RewriteEngine On
RewriteBase /test/
RewriteCond %{THE_REQUEST} /profile\.php\?username=([^\s&]+) [NC]
RewriteRule ^ profile/%1? [R=302,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^profile/(.+)$ profile.php?username=$1 [L,NC,QSA]
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_URI}\.php -f [NC]
RewriteRule ^(.+?)/?$ $1.php [L]
确保没有.htaccess
in /test/profile/
。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句