2010-07-06 225 views

回答

1

嘗試下列規則:

RewriteCond %{HTTPS} !=on [OR] 
RewriteCond %{HTTP_HOST} !=example.com 
RewriteRule^https://example.com%{REQUEST_URI} [L,R=301] 
RewriteRule ^$ subdirectory [L] 
+0

但它顯示出在地址欄中的子目錄名稱和https://example.com沒有按」 t重定向到https://example.com/subdirectory – 2010-07-06 06:02:20

0

這個怎麼樣(在甘博的回答大廈):

RewriteEngine On 

# Redirect direct subdirectory/ request to main domain 
RewriteCond %{THE_REQUEST} ^(POST|GET)\s/subdirectory 
RewriteRule ^subdirectory/?(.*)$ https://example.com/$1 [R=301,L] 

# Redirect www/non-https to https://example.com 
RewriteCond %{HTTPS}  !=on   [OR] 
RewriteCond %{HTTP_HOST} !=example.com 
RewriteRule ^.*$ https://example.com/$0 [R=301,L] 

# Redirect (internally) to subdirectory/ 
RewriteCond %{REQUEST_URI} !^/subdirectory/ 
RewriteRule ^.*$ subdirectory/$0 [L]