Rewrite all URL requests to https://www.example.com/$1
Posted
by
xylar
on Stack Overflow
See other posts from Stack Overflow
or by xylar
Published on 2013-11-05T09:43:13Z
Indexed on
2013/11/05
9:53 UTC
Read the original article
Hit count: 241
.htaccess
|mod-rewrite
I have two domains, example.com and example.co.uk, that use the same application on my server.
I would like to rewrite the address of the URL depending on what the user types in. The only URLs I want are https://www.example.com
and https://www.example.co.uk
In my .htaccess
file I have the following:
# Turn on URL rewriting
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example\.co.uk$ [NC]
RewriteRule ^(.*)$ https://www.example.co.uk/$1 [L,R=301]
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^(.*)$ https://www.example.com/$1 [L,R=301]
If I goto http://www.example.com
it doesn't add the https
, if I goto http://example.com
it does. What is the best way of making the ReWriteCond match the www url?
© Stack Overflow or respective owner