Search code examples
wordpressapachexampp

Wordpress website hosted on xampp only works when accessed with https


I have a wordpress website that is hosted on my pc. It runs on xampp. I added a domain name and https certificate, but some browsers (brave, opera gx) use http when searching for my domain name. So in short, accessing https://mysite.ro works, but http://mysite.ro doesn't. It gives me a "took too long to respond" error message. What did I do wrong? I want the wordpress site to work even with http, then redirect it to https. How can I manage this?

If you need any files tell me what to post. I'm kinda new to the whole web server thing so I don't know what files to attach.

I tried changing default wordpress site and home address from https to http. Still, only https worked.

EDIT: When entering my public ip address into the search bar it automatically redirects to "https://mysite.ro", which is good, but why isn't it working for the times is search for "http://mysite.ro"??


Solution

  • Have you got an .htaccess file in your root directory (public_html) folder?

    If so, if you add the following code before <IfModule mod_rewrite.c> RewriteEngine On

    Code to add:

    RewriteCond %{HTTP_HOST} ^mysite.ro [NC]
    RewriteRule ^(.*)$ https://mysite.ro/$1 [R=301,L]
    

    This will redirect the HTTP url of your website to the HTTPS one that you want to use.