Apache 如何使用htaccess重写get变量?

Apache 如何使用htaccess重写get变量?,apache,.htaccess,Apache,.htaccess,我有一个htaccess文件,可以重写链接 http://www.example.com/profiles.php?view_user=test 到 但是我想重写剩下的get变量-- 到 帮帮我,我对htaccess了解不多请尝试将这些规则添加到文档根目录中htaccess文件的适当位置: RewriteCond %{THE_REQUEST} \ /+profiles\.php\?([^=&]+)=([^&\ ]+) RewriteRule ^ /profiles/%1/%

我有一个htaccess文件,可以重写链接

http://www.example.com/profiles.php?view_user=test 


但是我想重写剩下的get变量--


帮帮我,我对htaccess了解不多

请尝试将这些规则添加到文档根目录中htaccess文件的适当位置:

RewriteCond %{THE_REQUEST} \ /+profiles\.php\?([^=&]+)=([^&\ ]+)
RewriteRule ^ /profiles/%1/%2? [L,R=301]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^profiles/([^/]+)/([^/]+)/?$ /profiles.php?$1=$2 [L,QSA]
还要确保已关闭“多视图”:

Options -Multiviews

您可以在
文档\u ROOT/.htaccess
文件中使用此代码:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(profiles)/([^/]+)/([^/]+)/?$ /$1.php?$2=$3 [QSA,L,NC]
RewriteCond %{THE_REQUEST} \ /+profiles\.php\?([^=&]+)=([^&\ ]+)
RewriteRule ^ /profiles/%1/%2? [L,R=301]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^profiles/([^/]+)/([^/]+)/?$ /profiles.php?$1=$2 [L,QSA]
Options -Multiviews
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(profiles)/([^/]+)/([^/]+)/?$ /$1.php?$2=$3 [QSA,L,NC]