I am redirecting example.com
to sample.com/?example
, so that I can have a modal popup saying, example has changed its name to sample.
It works fine for HTTP redirects from http://example.com
, and almost everything works for HTTPS redirects from https://example.com
, except for these two things (applying only to the redirects from https://example.com
):
In the address bar, it will still say
https://example.com
, but show the page forhttps://sample.com
. Whenever a link is clicked on this page, the problem is fixed and it then showshttps://sample.com
in the address bar.It will not keep the query that I add (
?example=1
).
Here are my .htaccess rules:
RewriteCond %{HTTPS} ^example.com$ [OR]
RewriteCond %{HTTPS} ^www.example.com$
RewriteRule (.*)$ https://www.sample.com/$1?example=1 [R=301,L]
How can I fix these so that when I go to https://example.com
, it goes to https://sample.com?example=1
NC
flag would be unnecessary, unless you specifically want to allow strange requests.) (I've removed the space from the _substitution URL - I assume that is not intentional, as per your comment)%{HTTPS}
contains either "on" or "off", so theRewriteCond
rules will always fail. Are you redirecting HTTP to HTTP and HTTPS to HTTPS, or everything to HTTPS?