htaccess RewriteRule 问题
我有一个 PHP 页面,在类别和页面中读取 $_GET 变量。
然后,我将 .htaccess 将 url.com/categroy/page 转发到 index.php 文件,以便它完成工作。
但是我无法让 htaccess 规则发挥作用
RewriteEngine On
RewriteRule ^/([^/]+)/(.[^/]) /index.php?category=$1&page=$2
RewriteRule ^/([^/]) /index.php?page=$1
关于我缺少什么有什么想法吗?
I have a PHP page reading $_GET variables in as category and page.
I then have the .htaccess forwarding url.com/categroy/page to the index.php file for it to do the work.
I cannot however get the htaccess rules working
RewriteEngine On
RewriteRule ^/([^/]+)/(.[^/]) /index.php?category=$1&page=$2
RewriteRule ^/([^/]) /index.php?page=$1
Any ideas as to what i am missing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的规则缺少结尾分隔符
$
。并且.
在该位置放错了。另外,您还需要第二个[]
字符类的+
量词:我对此不确定,但我还删除了前导
/
削减。当您将 .htaccess 放在根文件夹中时,它应该是隐式的。此外,您可能需要典型的 RewriteCond 来排除任何真实的文件名被重写。将其放在每个 RewriteRule 之前:
Your rules lack the endling delimiter
$
. And the.
is misplaced at that position. Also you need a+
quantifier for the second[]
character class:I'm not sure about this, but I also removed the leading
/
slash. It should be implicit when you place your .htaccess in the root folder.Additionally you probably will need the typical RewriteCond to exclude any real filenames from getting rewritten. Place this before each RewriteRule: