【发布时间】:2015-07-29 15:50:28
【问题描述】:
我的网站上有一系列子域,如下所示:
site.website.com/shop
site2.website.com/shop
对于我拥有商店的所有域,我希望通过 SSL 强制执行此操作。子域是否有通配符?我该怎么做?
【问题讨论】:
标签: .htaccess
我的网站上有一系列子域,如下所示:
site.website.com/shop
site2.website.com/shop
对于我拥有商店的所有域,我希望通过 SSL 强制执行此操作。子域是否有通配符?我该怎么做?
【问题讨论】:
标签: .htaccess
你可以用你的 .htaccess 做这样的事情:
RewriteEngine On
# force https
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NE]
# force www for main site
RewriteCond %{HTTP_HOST} ^domain\.com$ [NC]
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NE]
# remove www for app site
RewriteCond %{HTTP_HOST} ^www\.(app\.domain\.com)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [R=301,L,NE]
RewriteCond %{THE_REQUEST} \s/+app[/\s] [NC]
RewriteRule ^ / [R=301,L]
RewriteCond %{HTTP_HOST} ^app.domain.com$
RewriteCond %{REQUEST_URI} !^/app/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /app/$1
RewriteCond %{HTTP_HOST} ^app.domain.com$
RewriteRule ^(/)?$ app/index.php [L]
【讨论】: