特定的HTACCE重定向异常
我已经在.htaccess
特定条件的文件中创建了一个重定向:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^page/(.*) /clanky/?sf_paged=$1 [R=301,L]
</IfModule>
示例:
有人单击此链接:https://example.com/page/2/2/
重定向到:https://example.com/clanky/?sf_paged=2/
此场景完美效果。
现在,如果链接为:https://example.com/page/2/?s=zemedelec
- (排除条件应为/ ?s =
),在这种情况下,我不想使用任何重定向。
有什么想法,如何使这个例外?
I have created a redirection in .htaccess
file for specific condition:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^page/(.*) /clanky/?sf_paged=$1 [R=301,L]
</IfModule>
Example:
someone clicks on this link: https://example.com/page/2/
and they will be redirected to: https://example.com/clanky/?sf_paged=2/
This scenario works perfectly.
Now I need to make an exception for the case if a link will be: https://example.com/page/2/?s=zemedelec
- (the excluding condition should be /?s=
), in this case I don't want to use any redirection.
Any idea, how to make this exception?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为了在您的现有规则上进行例外,查询字符串以URL参数
s =
开始,然后您可以添加以下条件(rewriteCond
指令):当查询字符串不以
s =
开头时,否定条件!^s =
是成功的。以上未明确检查URL路径是否在斜线中结束,因此它也将排除表单
> https://的请求。 xxx.cz/page/2?s=zemedelec
。To make an exception on your existing rule for when the query string starts with the URL parameter
s=
then you can add the following condition (RewriteCond
directive):The negated condition
!^s=
is successful when the query string does not start withs=
.The above does not explicitly check that the URL-path ends in a slash, so it will also exclude requests of the form
https://xxx.cz/page/2?s=zemedelec
.