Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/qt/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.htaccess 如何指定HATCESS重写的长度_.htaccess_Rewrite - Fatal编程技术网

.htaccess 如何指定HATCESS重写的长度

.htaccess 如何指定HATCESS重写的长度,.htaccess,rewrite,.htaccess,Rewrite,如果我在重写,有没有办法区分字符串长度,比如如果是2个字符,它会转到一页,如果是3个或更多,它会转到另一页 RewriteRule ^([a-zA-Z0-9]+)/?$ two-characters.php?u=$1 [QSA] // 2 char RewriteRule ^([a-zA-Z0-9]+)/?$ three_plus_characters.php?u=$1 [QSA,L] // 3+ char 你可以这样试试你的规则 RewriteRule ^([a-zA-Z0-9]{2})/?

如果我在重写,有没有办法区分字符串长度,比如如果是2个字符,它会转到一页,如果是3个或更多,它会转到另一页

RewriteRule ^([a-zA-Z0-9]+)/?$ two-characters.php?u=$1 [QSA] // 2 char
RewriteRule ^([a-zA-Z0-9]+)/?$ three_plus_characters.php?u=$1 [QSA,L] // 3+ char

你可以这样试试你的规则

RewriteRule ^([a-zA-Z0-9]{2})/?$ two-characters.php?u=$1 [QSA] // 2 char
RewriteRule ^([a-zA-Z0-9]{3,})/?$ three_plus_characters.php?u=$1 [QSA,L] // 3+ char

我对第二条规则进行了快速编辑,以解释超过3条规则。