Php Setup.htacces用于非ww和在多域上使用ssl
我在网上到处找,但找不到一个干净的解决办法。 我不是.htaccess规则中的英雄,但我希望有一些规则可以强制用户在该服务器/安装的所有域中使用https和非www 我拿到了这个,但我卡住了Php Setup.htacces用于非ww和在多域上使用ssl,php,wordpress,apache,.htaccess,mod-rewrite,Php,Wordpress,Apache,.htaccess,Mod Rewrite,我在网上到处找,但找不到一个干净的解决办法。 我不是.htaccess规则中的英雄,但我希望有一些规则可以强制用户在该服务器/安装的所有域中使用https和非www 我拿到了这个,但我卡住了 # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f Rewrite
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
</IfModule>
#开始WordPress
重新启动发动机
重写基/
重写规则^index\.php$-[L]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则/index.php[L]
重写条件%{HTTP_HOST}^www\.(.*)$[NC]
重写规则^(.*)$https://%1/$1[R=301,L]
尝试以下代码:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [NE,R=301,L]
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [NE,R=301,L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
#开始WordPress
重新启动发动机
重写基/
重写条件%{HTTPS}关闭
重写规则^https://%{HTTP_HOST}%{REQUEST_URI}[NE,R=301,L]
重写cond%{HTTP_HOST}^www\.(.+)$[NC]
重写规则^https://%1%{REQUEST_URI}[NE,R=301,L]
重写规则^index\.php$-[L]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则/index.php[L]
还要确保WP permalink在站点和主页URL中有
https
和非www
URL。但这不是将所有内容重定向到domain.com而不是初始域吗?因此,我希望有几个域(aaa.com、bbb.com、ccc.com),并且都需要使用非ww和ssl。您在问题中没有提到有这么多域。如果是这种情况,那么您可以在301规则的顶部添加一个条件,如RewriteCond%{HTTP_HOST}^(www\.)?domain\.com$[NC]
。那么对于每个域,我必须添加该规则吗?