2017-12-01 3 views
0

Ich brauche jeden Aufruf einer bestimmten Subdomain (s) .example.com.xx fügen Sie das www am Anfang und dann umleiten es auf https. Auchhttp zu https Umleitung mit Subdomains und www Konvertierung über htaccess

Bei htaccess redirect to https://www gibt es eine Lösung, aber funktioniert nicht mit sub.example.com.xx Umleiten zu https://www.sub.example.com.xx

RewriteEngine On 
RewriteCond %{HTTPS} off 
# First rewrite to HTTPS: 
# Don't put www. here. If it is already there it will be included, if not 
# the subsequent rule will catch it. 
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] 
# Now, rewrite any request to the wrong domain to use www. 
# [NC] is a case-insensitive match 
RewriteCond %{HTTP_HOST} !^www\. [NC] 
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301] 

Wenn ich http://sub.example.com geben .., ich https://sub.example.com.xx und nicht https://www.sub.domain.com.xx

mit http://yyy.sub.example.com.xx muss mir https://www.yyy.sub.example.com.xx

Beispiele:

example.com.xx ---> https://www.example.com.xx 
http://example.com.xx ---> https://www.example.com.xx 
https://example.com.xx ---> https://www.example.com.xx 

sub.example.com.xx ---> https://www.sub.example.com.xx 
http://sub.example.com.xx ---> https://www.sub.example.com.xx 
https://sub.example.com.xx ---> https://www.sub.example.com.xx 

other.sub.example.com.xx ---> https://www.other.sub.example.com.xx 
http://other.sub.example.com.xx ---> https://www.other.sub.example.com.xx 
https://other.sub.example.com.xx ---> https://www.other.sub.example.com.xx 

Antwort

1

können Sie verwenden:

# redirect to www 
RewriteCond %{HTTP_HOST} !^www\. [NC] 
RewriteRule^https://www.%{HTTP_HOST}%{REQUEST_URI} [NE,L,R=301] 

# Redirect http to https 
RewriteCond %{HTTPS} off 
RewriteRule^https://%{HTTP_HOST}%{REQUEST_URI} [NE,L,R=301] 

www erste, eine doppelte Umleitung zu vermeiden.

+0

Versuchen Sie es jetzt. Aber lösche deinen Cache vorher! – Croises

+0

Ich habe meine Frage bearbeitet. Ihr letztes Beispiel funktioniert zumindest in dem Fall sub.example.com.xx. Vielen Dank . Ich muss die anderen Fälle testen. – FedeKrum

Verwandte Themen