957Htaccess and White-listing IPs

AuthUserFile /path/to/.htpasswd
AuthName "Restricted Access"
AuthType Basic
Require valid-user
Satisfy Any
Deny from All
Allow from 123.456.78.90

Allow IP ranges:

Allow from 123.456.78
Allow from 123.456

940Protecting a Single File with .htaccess

In .htaccess:
<Files myfile.php>
AuthType Basic
AuthName "Authentication Required"
AuthUserFile /path/to/.htpasswd
Require valid-user

937Creating entries for htpasswd

htpasswd -nb username password
Using just -n username will prompt twice for the password.
htpasswd -n username
From htpasswd man:
-n Don’t update file; display results on stdout.
-b Use the password from the command line rather than prompting for it.

918Permanent Redirect of all Subpages to new Server

LetsEncrypt will not autor-renew if it encounters a 301 Redirect. Which is NG, because it means httpswill stop working.
Not-so-elegant solution: use Redirecting with meta & refresh.

301 Redirect is great, if you want to keep you old structure and only change the server.


Redirect 301 / https://www.trembl.org/

Any page of your old.site/about would get redirected to https://www.trembl.org/about.

If you want to redirect all your page links from your old.site (e.g. old.site, old.site/aaa, old.site/bbb, ...) to https://www.trembl.org, use this RewriteRule:<


RewriteEngine On
RewriteRule ^(.*)$ https://www.trembl.org/ [R=301]

Meaning of 301 and 302

  • 301 Moved Permanently
  • 302 Moved Temporarily

864Pulling a GitHub Repository with Tokens & Webhooks

Here is how to sync a WordPress Theme from Github to your own server:

Create a Personal Access Token on GitHub

Webhook on GitHub:
Webhook on GitHub for .htaccess protected directory:
cd $temp_dir git init // initialize git git pull https://{$token}@github.com/{$repo}
<?php // path to local tmp directory $temp_dir = '/my/local/tmp/directory/'; // path to local theme directory $theme_dir = "/my/local/theme/directory/"; // access token from GitHub $token = 'abcdefghijk'; // Repo $repo = 'github.com/trembl/SuperNiceRepo.git'; // - - - - - // change to local git directory chdir($temp_dir); // resets local git echo exec('git reset --hard 2>&1') . ", "; // get latest from github echo exec("git pull https://$token@$repo 2>&1"); // delete theme dir echo "\n\nDeleting Theme Directory.\n"; echo exec("rm -rf $theme_dir*"); // * deletes all files within the directory // Copying Theme from $temp_dir to $theme_dir echo "\n\nCopying Theme from tmp folder to wp-content.\n"; echo exec("cp -a $temp_dir/* $theme_dir"); // cp -a $temp_dir/* copies everything _except_ invisible files, like .git ?> update.php protected by .htaccess? 860 Access a URL behind htaccess/htpasswd
Protect update.php ONLY with .htaccess? 940 Protecting a Single File with .htaccess

Q & A

I get the following error message: Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set). That means git is not initalized. Run git init

860Access a URL behind htaccess/htpasswd

Access a htaccess/htpasswd protected URL programmatically: https://username:passwd@www.trembl.org/protected/area/ See also: Pulling a GitHub Repository with Tokens & Webhooks