bschauer
bschauer

Reputation: 1008

Redirect all request to (from any domain) to the target domain (.htaccess)

I want to redirect all requests to a single domain.

The target domain should have https and www.

Request examples:

http://aaa.de  
http://www.aaa.de  
https://aaa.de  
https://www.aaa.de  

http://bbb.de  
http://www.bbb.de  
https://bbb.de  
https://www.bbb.de  

http://mydomain.de
http://www.mydomain.de

All that request should be redirected to: https://www.mydomain.de

Upvotes: 0

Views: 167

Answers (1)

anubhava
anubhava

Reputation: 785581

You can use this redirect rule in your site root .htaccess:

RewriteEngine On

RewriteCond %{HTTPS} !on [OR]
RewriteCond %{HTTP_HOST} !^www\.mydomain\.de$ [NC]
RewriteRule ^ https://www.mydomain.de%{REQUEST_URI} [R=301,L,NE]

Make sure to use a new browser for your testing to avoid old browser cahhe.

Upvotes: 1

Related Questions