开发者

htaccess rewriterule help needed

I'm trying to get some rewriterules working. Htaccess is enabled, the mod-rewrite loads. It should work as follows:

  • / => homepage
  • /abc => /index.php?x=abc
  • /abc/def => /index.php?x=abc&y=def
开发者_JS百科
RewriteEngine On
RewriteBase /
RewriteRule /           /index.php
RewriteRule /([a-z]+)       /index.php?x=$1
RewriteRule /([a-z]+)/([a-z]+)  /index.php?x=$1&y=$2

If I try this, the homepage works, but the rest results in a 404 error. What is wrong here?


You need to omit the contextual path prefix and should limit the pattern:

RewriteRule ^$           /index.php
RewriteRule ^([a-z]+)$       /index.php?x=$1
RewriteRule ^([a-z]+)/([a-z]+)$  /index.php?x=$1&y=$2
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜