Redirecting site url from http://mydomain.epizy.com to https://new-domain-name (still hosted at epizy.com)

im back again

is it posible to set a rule in .htaccess or some other way that can check the url and redirect ?

I have a domain name https://lovebug.ml registered to http://lovebug.epizy.com which has cloudflare enabled for ssl and is working great

if someone visits http://lovebug.epizy.com instead of https://lovebug.ml they get the insecure connection

so I was wondering if theres a way to detect the url and if its http://lovebug.epizy.com it will redirect to https://lovebug.ml

can that be done ?

thanks

would this work ? I dont want to try it in case something goes terribly wrong :frowning:

RewriteRule ^(.*)epizy(.*)$ https://lovebug.ml/ [L,R=301]

---------------- edit ------------------
I tried it and it didnt work, maybe I got it wrong ?

ive added this to my index.php file right at the top before anything else and now visiting http://lovebug.epizy.com redirects to https://lovebug.ml which is still hosted at epizy.com

// redirect browser to secure site http://lovebug.ml if trying to browse insecure site http://lovebug.epizy.com
if(strpos($_SERVER['SERVER_NAME'], 'lovebug.epizy.com') !== false)
{
	header("Location: https://lovebug.ml/", true, 301);
	exit();
}

but im not sure if its possiible to redirect https://lovebug.epizy.com to https://lovebug.ml

Im sorry, I know I keep asking questions and then finding solutions but I just scared of breaking something and dont like to risk things

I think you cannot redirect the homepage to another website. I did the same thing as you are doing once and my hosting was suspended. The person at support told me that I am not allowed to do this.

1 Like

RewriteRule matches based on URLs, not domain names. But you can do this with RewriteCond and the HTTP_HOST variable.

4 Likes

ah thanks admin, that makes sense

@yoptgyo I hope this its gonna be ok, my site is actually hosted at http://lovebug.epizy.com im just redirecting my subdomain name to my new domain name @ https://lovebug.ml, a lot of people know my site as epizy so im just trying to forward them to my new domain name in case they go to the old name

I guess the title is confusing, i’ll edit it again :slight_smile:

Here is what i use:

Redirect all pages: Redirect 301 / https://example.com/

Redirect a certain file to another site Redirect /path/to/old/file/old.html http://www.example.com/new/file/new.html

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.