的.htaccess使用转义报价 [英] .htaccess using escape quotes
本文介绍了的.htaccess使用转义报价的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这样的.htaccess:
I have this .htaccess:
RewriteRule ^(aa.bbb|aaa,bbb|aaa-bbb|aaa_bbb||)/(.*)$ /index.html [L,NC]
会不会是细如上面还是应与espae报价。我知道在JavaScript通常\使用。如下图所示:
Will it be fine as above or should it be with espae quotes. I know in javascript is often \ in use. Like below:
RewriteRule ^(aa\.bbb|aaa,bbb|aaa-bbb|aaa_bbb)/(.*)$ /index.html [L,NC]
我需要它 - _。他们四个。我是否需要\或在.htaccess其他一些迹象是什么呢。
I need it for - _ , . all four of them. Do I need \ or some other sign in .htaccess and what is it.
推荐答案
- 从你的规则只点需要转义(因为这是特殊的正则表达式字符)
- 在两个
||
应删除,否则可以匹配空字符串 - 您可以使用字符类,大大降低您的正则表达式
- 在字符类没有这些字符需要转义。
- From your rules only dot needs to be escaped (since that is special regex character)
- Two
||
should be removed otherwise that can match empty string - You can use character class to greatly reduce your regex
- Inside character class none of these character need to be escaped.
您可以使用此规则:
RewriteRule ^(aa[.,_-]bbb)/(.*)$ /index.html [L,NC]
这篇关于的.htaccess使用转义报价的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文