简体   繁体   中英

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

I have the following .htaccess file but parts of the site are accessible without "www". How can I change my htaccess so that all urls of my site are only accessible with "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>

i hope somebody can help?

edit: when i use this rule from an other post:

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

the problem is not solved. All the pages are working correctly with https and with www. But all images in the folder wp-content/uploads are still accessible without www and with http. The site is hochzeitshaus-leipzig.de

i dont see the mistake...

Check RewriteCond

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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