我是.htaccess的新手,在让它为我清理url时似乎遇到了一些问题。
我有
site.com?p=article&id=3&read=article title
我能够使第一个变量像site.com/articles
一样正常工作。但是当我尝试更进一步时,服务器说找不到它。我已经尝试了几种方法,但似乎都不起作用。
RewriteRule ^([a-zA-Z0-9]+)$ index.php?p=$1
RewriteRule ^([a-zA-Z0-9]+)/$ index.php?p=$1
上面这个是工作
我试过
RewriteRule ^([a-zA-Z0-9-z'-]+)(/([a-zA-Z0-9-z'-]+))?/?$ index.php?p=$1&i=$2
和
RewriteRule ^([a-zA-Z0-9-z'-]+)/([a-zA-Z0-9-z'-]+)/([a-zA-Z0-9-z'-]+)/?$ index.php?p=$1&i=$2&read=$3
最后两个不起作用。请帮忙。感谢
让我们试试这样的东西?
RewriteEngine On
RewriteRule ^([^/]*)/([^/]*)/([^/]*)$ /index.php?p=$1&id=$2&read=$3 [L]
%{QUERY_STRING}就是您想要的。
这是我在类似情况下使用的:
RewriteRule ^/(.*) /index.php?r=/$1&%{QUERY_STRING} [L]