Apache htaccess和具有多个参数的友好URL

Apache htaccess和具有多个参数的友好URL,apache,.htaccess,redirect,friendly-url,Apache,.htaccess,Redirect,Friendly Url,我没有使用htaccess的经验,所以我有一个url:index.php?id=1163&sub=hp 我已使用htaccess成功地将第一部分转换为友好的url: <IfModule mod_rewrite.c> RewriteEngine on RewriteRule ^([a-zA-Z0-9_-]+)$ index.php?perf=$1 Options -Indexes RewriteEngine On RewriteCond %{HTTP_HOST} ^www.mytes

我没有使用htaccess的经验,所以我有一个url:index.php?id=1163&sub=hp 我已使用htaccess成功地将第一部分转换为友好的url:

<IfModule mod_rewrite.c> 
RewriteEngine on
RewriteRule ^([a-zA-Z0-9_-]+)$ index.php?perf=$1
Options -Indexes
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.mytesturl.com
RewriteRule (.*) http://www.mytesturl.com/$1 [R=301,L]
</IfModule>  
www.mytesturl.com/index.php?id=1163进入www.mytesturl.com/computers/ 但是,我需要将整个url转换为两个参数,例如: www.mytesturl.com/index.php?id=1163&sub=hp进入www.mytesturl.com/computers/hp/

以下是我的访问权限:

<IfModule mod_rewrite.c> 
RewriteEngine on
RewriteRule ^([a-zA-Z0-9_-]+)$ index.php?perf=$1
Options -Indexes
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.mytesturl.com
RewriteRule (.*) http://www.mytesturl.com/$1 [R=301,L]
</IfModule>  
有人能给我指一下正确的方向吗?第二条指令应该在同一行上,或者它必须添加另一条规则或指令 类似于:RewriteRule.$1[R=301,L]

您可以使用:

RewriteEngine On

RewriteRule ^([\w-]+)/?$ index.php?perf=$1 [L,QSA]

RewriteRule ^([\w-]+)/([\w-]+)/?$ index.php?perf=$1&sub=$2 [L,QSA]
但请记住您的规则正在使用?perf=。。。第一个参数不是?id=。。。正如你的问题所说