我目前在.htaccess文件中重写索引url有问题,我知道如果我使用
RewriteRule ^profile/([^/]*)/?$ /profile.php?x=$1 [L]我可以使用www.example.com/profile/get或www.example.com/profile/get/ (附带或不带尾斜杠)
但我想要的是www.example.com/到目前为止
RewriteRule ^([^/]*)\/$ /index.php?x=$1 [L]但如果我放了一个?在$ it错误之前,欢迎任何答案。
发布于 2013-08-11 14:16:49
使尾斜杠可选将导致无限循环,因为[^/]*将匹配任何不包括/的内容,即它也将匹配index.php?x=get
您可以通过设置规则有条件地适用来避免这种情况,例如通过测试reqeust URI:
RewriteCond %{REQUEST_URI} !^/index\.php.*
RewriteRule ^([^/]*)\/?$ /index.php?x=$1 [L]这样,只有在请求URI不以/index.php开头时,规则才能适用
https://stackoverflow.com/questions/18171183
复制相似问题