将一个子域重定向到另一个子域而不更改URL

时间:2015-07-31 06:47:51

标签: .htaccess

这是我正在尝试用htaccess做的事情,但找不到我的方式:

$array = array('a' => 'a', 'b' => 'b', 'c' => 'c', 'd' => 'd');
function formatting(&$arr, $key) {
    global $array;
    $array[$key] = ":$arr";
}
array_walk($array, 'formatting');
print_r($array);

1 个答案:

答案 0 :(得分:0)

# Force www prefix
RewriteCond %{HTTP_HOST} ^example\.com$
RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L]
# Force https prefix on www subdomain
RewriteCond %{SERVER_PORT} 80 
RewriteCond %{HTTP_HOST} ^www\.example\.com$
RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L]
# Move non-www to subdomain 'web'
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule !^web/ /web%{REQUEST_URI} [L,NC]
RewriteEngine On