开发者

.htaccess something wrong with code

RewriteRule ^gro开发者_JAVA技巧ups/([0-9+]*)/(.*)$ /users.php?group=$1 [QSA,L,E]

www.mysite.com/groups/11/all-users

in users.php i try get group id: echo $_GET['group'];

Why always get "false"?

Thanks


I heartily recommend using the RewriteLog functionality for debugging your rewrite rules, I find it helps immensely to demystify what's happening inside. http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html#rewritelog

From what I can tell, you're merely missing the leading slash in the URL. I tested locally using (note the added leading slash before groups):

RewriteRule ^/groups/([0-9+]*)/(.*)$ /users.php?group=$1 [QSA,L,E]

The resulting page does a vardump of $_GET, providing:

array(1) { ["group"]=> string(2) "11" }


Try with this:

Example:

The original URL: http://www.mysite.com/users.php?group=1

The rewritten URL: http://www.mysite.com/group/1

RewriteEngine On
RewriteRule ^group/([^/]*)$ /users.php?group=$1 [L]
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜