我有一个带有多个域的服务器。我只想将一个“site-internet.com”重定向到 ssl 配置。
我想做:
这是我的 apache conf 文件
NameVirtualHost *:80
<VirtualHost *:80>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^test.site-internet\.com$[NC]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ http://test.site-internet.com/$1 [NC,R=301,L]
RewriteCond %{HTTP_HOST} ^(.*)\.site-internet\.com$
RewriteCond %{HTTP_HOST} ^site-internet\.com$
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [NC,R=301]
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)
但这不起作用。我应该纠正什么?
因此,当您放置 2 个 RewriteCond 时,它们是“AND”-ed,这意味着它们都需要为真才能应用 RewriteRule。您需要使用 [OR] 来克服这个问题。另外,我不明白为什么你需要“不重定向”的代码。
<VirtualHost *:80>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.site-internet\.com$ [OR]
RewriteCond %{HTTP_HOST} ^site-internet\.com$
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [NC,R=301]
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1092 次 |
最近记录: |