的.htaccess使用转义报价htaccess

2023-09-02 00:56:56 作者:我也曾经炫耀过你的好

我有这样的.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]
 
精彩推荐
图片推荐