正则表达式 utf-8 阿拉伯语
Regex utf-8 arabic
当我的 slug 中有 utf-8(阿拉伯语)时,我有 404 NOT FOUND url
php 文件中有我的代码:
'slug' => '[A-Za-z0-9\_-]+'
这在 htaccess 文件中:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
#Charset
AddDefaultCharset utf-8
#Protect - DOS
LimitRequestBody 10000000
#Index Protect
Options All -Indexes
<Files .htaccess>
order allow,deny
deny from all
</Files>
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ / [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
RewriteCond %{THE_REQUEST} ^[a-zA-Z0-9\-_]{3,}\s(.*)/index\.php [NC]
RewriteRule ^ %1 [R=301,L]
当我 link 喜欢 : www.test.com/تست
服务器 return 404 未找到,当我使用
'slug' => '[ا-یa-zA-Z0-9\-_]+'
htaccess 也一样,我有循环重定向!
ا-ьa-zآ-A-Z
尝试将正则表达式的字符 class 部分更改为 [\p{L}\p{N}\p{Pd}_]
\p{L}
匹配任何符合字母但不是下划线的 unicode
\p{N}
匹配任何看起来像数字的东西
\p{Pd}
是包含连字符的标点破折号。
有关 Unicode 正则表达式的更多信息,请参阅 here
您可以使用 ([^/]+)
,它有效!
此模式允许除斜杠以外的所有内容。
当我的 slug 中有 utf-8(阿拉伯语)时,我有 404 NOT FOUND url
php 文件中有我的代码:
'slug' => '[A-Za-z0-9\_-]+'
这在 htaccess 文件中:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
#Charset
AddDefaultCharset utf-8
#Protect - DOS
LimitRequestBody 10000000
#Index Protect
Options All -Indexes
<Files .htaccess>
order allow,deny
deny from all
</Files>
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ / [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
RewriteCond %{THE_REQUEST} ^[a-zA-Z0-9\-_]{3,}\s(.*)/index\.php [NC]
RewriteRule ^ %1 [R=301,L]
当我 link 喜欢 : www.test.com/تست 服务器 return 404 未找到,当我使用
'slug' => '[ا-یa-zA-Z0-9\-_]+'
htaccess 也一样,我有循环重定向!
ا-ьa-zآ-A-Z
尝试将正则表达式的字符 class 部分更改为 [\p{L}\p{N}\p{Pd}_]
\p{L}
匹配任何符合字母但不是下划线的 unicode
\p{N}
匹配任何看起来像数字的东西
\p{Pd}
是包含连字符的标点破折号。
有关 Unicode 正则表达式的更多信息,请参阅 here
您可以使用 ([^/]+)
,它有效!
此模式允许除斜杠以外的所有内容。