清洁的.htaccess URL超过3 paramenters清洁、htaccess、paramenters、URL

2023-09-02 09:51:33 作者:小橘子

我是新来的.htaccess,我似乎有一些问题得到它清理网址给我。

I am new to .htaccess and I seem to be having some problems getting it to clean up the url for me.

site.com?p=article&id=3&read=article title

我能够得到的第一个工作确定像 site.com/articles 变量。但是当我尝试走得更远服务器说它不能找到它。我尝试了好几种方法,其中没有一个似乎工作。

I am able to get the first variable to work ok like site.com/articles. but when I try to go further the server is saying it cant find it. I have tried several methods none of which seem to be working.

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

在过去2不工作。请帮助。谢谢

the last 2 are not working. help please. Thanks

推荐答案

%{QUERY_STRING}是你所期待的。

%{QUERY_STRING} is what you are looking for.

这是我使用了类似的情况:

this is what I use for a similar situation:

RewriteRule   ^/(.*)  /index.php?r=/$1&%{QUERY_STRING} [L]