我怎样才能做到这一点:
Redirect permanent /ANY_TWO_CHARACTERS/secure/ANY_PATH https://example.com/THE_ANY_TWO_CHARACTERS/secure/ANY_PATH
我试过了:
Redirect permanent /(..)/secure(.*) https://example.com/secure$1
它不工作。怎么了?
您不能将正则表达式与Redirect
指令一起使用,您需要使用RedirectMatch
:
RedirectMatch permanent ^/../secure/(.*)$ https://example.com/secure/$1
您的正则表达式将 a(..)
作为第一个分组,因此$1
将是那些“ANY_TWO_CHARACTERS”而不是“ANY_PATH”。
尝试:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^/?../clients/ https://example.com%{REQUEST_URI} [L,R=301]