문제

I need help with rewrite rules.

So I want that these addresses:

http://domain.com
http://www.domain.com
https://www.domain.com

Redirect to:

https://domain.com

Can someone help me?

Right now I have rule:

RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://domain.com/$1 [R,L]

But it doesnt redirect https://www to https://
도움이 되었습니까?

해결책

Place this rule in your DOCUMENT_ROOT/.htaccess file:

RewriteEngine On

RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} www\.
RewriteRule ^ https://domain.com%{REQUEST_URI} [L,R=301,NE]
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top