条件重写规则 - 如何仅应用这两组规则中的一组

发布于 2024-09-09 11:03:22 字数 657 浏览 2 评论 0原文

如果从 project_name 开始的第一个位置有 browse_by_exammy_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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

猫弦 2024-09-16 11:03:22

我自己找到了解决方案。以下工作有效:-

############Following rules apply only to browse_by_exam and my_study_centre

RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 ^(browse_by_exam|my_study_centre) 

RewriteRule ^(.*)$ index.php [L,QSA]
#################################################


###Following rules apply to all other pages (other than browse_by_exam and my_study_centre)
RewriteRule ^([a-zA-Z0-9\-\_]+)/?$ index.php?a=$1 

RewriteRule ^([a-z0-9\-\_]+)/([a-z0-9\-\_]+)/?$ index.php?a=$1&b=$2

RewriteRule ^([a-z0-9\-\_]+)/([a-z0-9\-\_]+)/([a-zA-Z0-9\-\_+]+)/?$ index.php?a=$1&b=$2&c=$3

RewriteRule ^([a-z0-9\-\_]+)/([a-z0-9\-\_]+)/([a-zA-Z0-9\-\_+]+)/([0-9]+)/?$ index.php?a=$1&b=$2&c=$3&d=$4

干杯,

Sandeepan

I found the solution myself. The following worked:-

############Following rules apply only to browse_by_exam and my_study_centre

RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 ^(browse_by_exam|my_study_centre) 

RewriteRule ^(.*)$ index.php [L,QSA]
#################################################


###Following rules apply to all other pages (other than browse_by_exam and my_study_centre)
RewriteRule ^([a-zA-Z0-9\-\_]+)/?$ index.php?a=$1 

RewriteRule ^([a-z0-9\-\_]+)/([a-z0-9\-\_]+)/?$ index.php?a=$1&b=$2

RewriteRule ^([a-z0-9\-\_]+)/([a-z0-9\-\_]+)/([a-zA-Z0-9\-\_+]+)/?$ index.php?a=$1&b=$2&c=$3

RewriteRule ^([a-z0-9\-\_]+)/([a-z0-9\-\_]+)/([a-zA-Z0-9\-\_+]+)/([0-9]+)/?$ index.php?a=$1&b=$2&c=$3&d=$4

Cheers,

Sandeepan

羁绊已千年 2024-09-16 11:03:22

这些 URL 均与您的两条规则的模式不匹配。但如果您想编写符合您的条件的规则,请尝试这样的规则:

RewriteRule ^(browse_by_exam|my_study_centre)($|/) foobar [L]

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:

RewriteRule ^(browse_by_exam|my_study_centre)($|/) foobar [L]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文