条件重写规则 - 如何仅应用这两组规则中的一组
如果从 project_name
开始的第一个位置有 browse_by_exam
或 my_study_centre
,则
http://project_name/browse_by_exam/type/classes/...
http://project_name/my_study_centre/page_sort/1,20,name,asc/...
应用这 2 条规则:-
RewriteRule ^([a-zA-Z0-9\-\_]+)/?$ index.php?a=$1
RewriteRule ^([a-z0-9\-\_]+)/([a-z0-9\-\_]+)/?$ index.php?a=$1&b=$2
对于所有其他 URL,应用这些规则:-
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [L,QSA]
谢谢,
桑迪潘
If there is browse_by_exam
or my_study_centre
in the 1st position starting from project_name
as in
http://project_name/browse_by_exam/type/classes/...
http://project_name/my_study_centre/page_sort/1,20,name,asc/...
Then apply these 2 rules:-
RewriteRule ^([a-zA-Z0-9\-\_]+)/?$ index.php?a=$1
RewriteRule ^([a-z0-9\-\_]+)/([a-z0-9\-\_]+)/?$ index.php?a=$1&b=$2
For all other URLs apply these rules:-
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [L,QSA]
Thanks,
Sandeepan
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我自己找到了解决方案。以下工作有效:-
干杯,
Sandeepan
I found the solution myself. The following worked:-
Cheers,
Sandeepan
这些 URL 均与您的两条规则的模式不匹配。但如果您想编写符合您的条件的规则,请尝试这样的规则:
None of these URLs are matched by the patterns of your two rules. But if you want to write rules that match your conditions, try a rule like this: