开发者

Apache RewriteRule: Which one has the best performance: ^(.+) vs (.*) and ^.*$ vs .*$ ? Is there any difference?

开发者 https://www.devze.com 2023-02-05 20:19 出处:网络
Is there any different between ^(.+) and (.*)? RewriteRule ^(.+)/$ /$1 [R=301,L] RewriteRule (.*)/$ /$1 [R=301,L]

Is there any different between ^(.+) and (.*)?

RewriteRule ^(.+)/$ /$1 [R=301,L]
RewriteRule (.*)/$ /$1 [R=301,L]

And between ^.*$ and .*$?

开发者_开发百科
RewriteCond %{QUERY_STRING} ^id=(.*)$
RewriteRule ^.*$ %{REQUEST_URI}%1? [R=301,L]
RewriteRule .*$ %{REQUEST_URI}%1? [R=301,L]

Which one has the best Apache .htaccess performance?


They are not even equal. The first variant requires at least one character at the beginning, and the other also matches the single slash. Sorry, I don't know enough about these regexes to make a guess about the performance, but despite the difference, they should be equal.

0

精彩评论

暂无评论...
验证码 换一张
取 消