HTTP to HTTPS (And redirection to other website)

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Redirect 301 / TikTok

Hold on, I mistyped before, there should be two htaccess files, on in htdocs and one in the root.

Can you share the full contents of both of them?


It’s a long discussion, if you wanted that whenever someone types or, they should be taken to
Here’s code:

DirectoryIndex index.php index.html index.htm index2.html

ErrorDocument 400
ErrorDocument 401
ErrorDocument 403
ErrorDocument 404
ErrorDocument 503

RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteCond %{HTTPS} off
RewriteCond %{HTTP:CF-Visitor} !{"scheme":"https"}
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Delete htaccess from root. Create new one inside htdocs/, paste the code.
Remember to change error pages to your own.

1 Like

I don’t know if it’s because you’ve changed something, but your site already works the way you want it to. It just isn’t seen by the naked eye because, immediately after redirecting visitors to the HTTPS version, it redirects them to TikTok as you intended it to.

You can see what I mean by using a tool that traces redirects, such as the one I used.


I just stopped using infinityfree.

This thread can be closed.

Just FYI: our own redirects tool only shows http:// as prefix in the list, but it also redirects https://, http://www. and https://www..

I’m not entirely sure where and how you got the “not secure” error, but I can tell you that if you want to redirect a website over HTTPS, the source domain also needs to support HTTPS, i.e. have a valid SSL certificate.

And both redirecting an entire site and setting up forced HTTPS is unnecessary. It really doesn’t matter if you redirect from to to, or straight from to The first option just slows things down for no reason.


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