Skip to main content

Posts

Showing posts with the label HTAccess

Direct access to phpMyAdmin

If you would like an easy way to have phpmyadmin.yourdomain.com automatically go to a secure page for phpMyAdmin, just put these three lines at the top of your .htaccess file:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^phpmyadmin\.
RewriteRule ^(.*)$ https://yourserver.site5.com:2083/3rdparty/phpMyAdmin/index.php [L]
substitute yourserver with the name of your site5 server.
One more fine point.  If you are using multiSite, you will need to put that code in the primary domain name .htaccess file.  At site5, all undefined subdomains for any domain name are routed to the primary domain name.
Avoid hard coding the path There are times when you want to code the full path in a script.  For example, this could be done for includes where you are using the same code in many locations on your site.  Many of the scripts on this page require a file path.  Don't hard code the value in your scripts, as you make the scripts less portable and you are giving away your username if someone is able to gain…

Ban IP Addresses (not using htaccess)

This script can be used to ban an IP Address from any function on your site.   While a .htaccess file can be used to ban, it cannot be selective by function.   The script will also ban based on partial IP Addresses.   In this example the banned IP Addresses are in a file called IP.dat (in the same directory as the script) with one address per line.

- - Start Script Here - -
<?php
$IP = $_SERVER['REMOTE_ADDR'];$IP_array = file('IP.dat');$IP_array = str_replace("\n", "", $IP_array);$IP_array = str_replace("\r", "", $IP_array);
foreach ($IP_array as $IP_test) {
  if (substr_count($IP, $IP_test) != "0") {
    echo "<script type='text/javascript'>
    alert ('Your IP Address has been banned from the Member's Only Area.');
    self.location.replace('banned.htm');
    </script>";
    die();
  }
}?>
- - End Script Here - -


Using subdomains with multiSite If you have a mutliSite account …