我需要有关多个参数的rewriteRule的帮助,如下所示:
sitename.com/profile/index.php?t=value1&a=value2
成为
sitename.com/profile/value1-value2
我尝试了这段代码,但没有解决。
RewriteEngine On
RewriteBase /
RewriteRule ^([a-zA-Z0-9_-]+)$ index.php?id=$1&id2=$2
RewriteRule ^([a-zA-Z0-9_-]+)$ index.php?id=$1&id2=$2
RewriteRule ^([^/]+)/([^/]+)/?$ $1-$2 [NE,L,R=302]
RewriteRule ^([^/]+)/(.+)$ $1-$2
答案 0 :(得分:0)
由于您已添加php
标记,您可以执行此操作,将.htaccess文件放在配置文件目录中
<强> htaccess的强>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^([a-zA-Z-_]+)$ index.php?t=$1
<强> PHP 强>
$var = $_GET['t'];
$var1 = explode("-", $var);
echo $t = $var1[0];
echo $a = $var1[1];