Category Archives: Hosting24

How Can I Find MySql Hostname From My Hosting24 Server

I have bought a Hosting24 plan, I would like to know my mysql hostname

Normally, the MySQL hostname is “localhost”. However You can double check your mysql hostname in your Hosting24 Members area -> List accounts -> Account details.

1. If you are trying to connect to MySQL from a remote location, Your server IP address can be found from left hand column of your Hosting24 cPanel.

2. Adding your computer IP address to your Hosting24 cPanel -> Remote MySQL section. You can get your computer IP address at http://softwarehtec.com/getip/

3. Use your MySQL username / password to connect to your Hosting24 database.

How To Redirect NON WWW To WWW Or WWW To NON WWW From Hosting24 Hosting

I am using Hosting24 Hosting, How can I redirect www url to without www url or without www url to with www url

Here are some methods can help you redirect non www url to www url or www url to non www url for your Hosting24 Hosting

.htaccess

non www to www

RewriteCond %{HTTP_HOST} ^yourdomain.com [NC]
RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [L,R=301]

www to non www

RewriteEngine On
RewriteCond %{HTTP_HOST} !^yourdomain\.com
RewriteRule (.*) http://yourdomain.com/$1 [R=301,L]

PHP

www to non www

if (substr($_SERVER['HTTP_HOST'], 0, 4) === 'www.') {
    header('Location: http'.(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS']=='on' ? 's':'').'://' . substr($_SERVER['HTTP_HOST'], 4).$_SERVER['REQUEST_URI']);
    exit;
}

non www to www

if (substr($_SERVER['HTTP_HOST'], 0, 4) != 'www.') {
    header('Location: http'.(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS']=='on' ? 's':'').'://www.' . $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
    exit;
}

cPanel

www to non www or non www to www

Home >> Domains >> Redirects >> Add a redirect

How To Redirect HTTPS To HTTP Or HTTP To HTTPS From Hosting24 Hosting

I am using Hosting24 Hosting, How can I redirect https to http url or http to https url

Here are some methods you can redirect https to http or http to https url for your Hosting24 Hosting

.htaccess

http to https

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L]

https to http

RewriteEngine On
RewriteCond %{SERVER_PORT} 443
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]

PHP

http to https

if($_SERVER["HTTPS"] != "on"){
    $host = $_SERVER['HTTP_HOST'];
    $request_uri = $_SERVER['REQUEST_URI'];
    $new_url = "https://" . $host . $request_uri;
    header( "HTTP/1.1 301 Moved Permanently" );
    header( "Location: $new_url" );
    exit;
}

https to http

if($_SERVER["HTTPS"] == "on"){
    $host = $_SERVER['HTTP_HOST'];
    $request_uri = $_SERVER['REQUEST_URI'];
    $new_url = "http://" . $host . $request_uri;
    header( "HTTP/1.1 301 Moved Permanently" );
    header( "Location: $new_url" );
    exit;
}

cPanel

http to https

Home >> Domains >> Redirects >> Add a redirect