永久重定向(SSL)

时间:2013-07-10 00:04:07

标签: apache .htaccess

我该怎么做:

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

它不起作用。怎么了?

1 个答案:

答案 0 :(得分:1)

您无法使用带有Redirect指令的正则表达式,您需要使用RedirectMatch

RedirectMatch permanent ^/../secure/(.*)$ https://example.com/secure/$1

你的正则表达式有(..)作为第一个分组,因此$1将是那些“ANY_TWO_CHARACTERS”而不是“ANY_PATH”。


尝试:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^/?../clients/ https://example.com%{REQUEST_URI} [L,R=301]