繁体   English   中英

从http重定向到https,没有www到www无法正常工作

[英]redirect from http to https and without www to www does not work correctly

我有以下.htaccess文件,但网站的部分可以访问没有“www”。 如何更改我的htaccess以便我的网站的所有网址只能通过“www”访问?

<IfModule mod_rewrite.c>
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

我希望有人可以帮忙吗?

编辑:当我从其他帖子使用此规则时:

RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ https://www.yourdomain.com%{REQUEST_URI} [R=301,L,NE]

问题没有解决。 所有页面都可以正常使用https和www。 但是文件夹wp-content / uploads中的所有图像仍然可以在没有www和http的情况下访问。 该网站是hochzeitshaus-leipzig.de

我没有看到错误......

检查RewriteCond

RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ https://www.example.com/$1 [L,R=301,NC]

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM