문제

I have two domains pointing to the same website, domain A and domain B. I want:

  • Domain A to be accessible via HTTP (works fine out of the box)
  • Domain B to redirect all requests to HTTPS. Basically if you type in http://domainb.com/somepage to redirect to http*s*://domainb.com/somepage. I would prefer to have this done via htaccess file.

I tried many solutions and I always get into redirection loop. Eg. I tried this:

RewriteCond     %{SERVER_NAME} ^www\.domainb\.com$ [NC]
RewriteCond %{HTTPS} off
RewriteRule     ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]
....
rest of the standard typo3 htaccess commands. 

My code was after typo3 be redirection part and before "Main URL rewriting" part in the htaccess file. With code above I'm redirected to https but then "redirection loop" error is shown.

Any help is highly appreciated.

도움이 되었습니까?

해결책

This works for me :)

RewriteCond %{HTTPS} !on
RewriteCond %{HTTP_HOST} domainb\.com$
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]

I include this code right after this line with RewriteEngine On.

다른 팁

Try this:

RewriteRule ^http://www\.domainb\.com/(.*) https://www\.domainb\.com/$1 [R=301,L]

The only solution that worked for me was the following one:

RewriteCond %{SERVER_PORT} !^443$
RewriteRule (.*) https://%{HTTP_HOST}/$1 [R=301,L]
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top