Apache .htaccess SSL和非SSL,带www到非www重定向
我在这里使用了各种答案来创建下面的.htaccess脚本。我需要脚本做的是 1将所有www重定向到非www,例如将www.example.com重定向到example.com 2将页面末尾的php(例如www.example.com/store.php)丢失到example.com/store 3将特定页面的所有点击重定向到安全HTTPS版本,例如 我已经成功地完成了上面的所有工作,除了能够为https页面将www重定向到非www。下面是我的代码Apache .htaccess SSL和非SSL,带www到非www重定向,apache,.htaccess,redirect,ssl,https,Apache,.htaccess,Redirect,Ssl,Https,我在这里使用了各种答案来创建下面的.htaccess脚本。我需要脚本做的是 1将所有www重定向到非www,例如将www.example.com重定向到example.com 2将页面末尾的php(例如www.example.com/store.php)丢失到example.com/store 3将特定页面的所有点击重定向到安全HTTPS版本,例如 我已经成功地完成了上面的所有工作,除了能够为https页面将www重定向到非www。下面是我的代码 RewriteEngine On Rewrite
RewriteEngine On
RewriteBase /
Options +FollowSymlinks
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
RewriteCond %{HTTPS} off
RewriteRule ^secure-page\.php$ https://example.com/secure-page [L,R=301]
RewriteCond %{HTTPS} off
RewriteRule ^secure-page/ secure-page [R=301,L]
RewriteCond %{HTTPS} on
RewriteRule ^secure-page/ secure-page [R=301,L]
我试着加上这句话
RewriteCond %{HTTP_HOST} ^[^.]+\.[^.]+$
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
但这似乎不起作用。0重写引擎和选项:
RewriteEngine On
RewriteBase /
Options +FollowSymlinks +MultiViews
1将www重定向到非www:
RewriteCond %{HTTP_HOST} ^www\.
RewriteRule (.*) http://example.com%{REQUEST_URI} [L,R=301]
2使用“多视图”选项
3重定向到https:
RewriteCond %{HTTPS} off
RewriteRule ^secure-page https://example.com/secure-page [L,R=301]