Source Code



Allow Single URL Through .htaccess Password Protection

  • css-tricks
  • 20 November 2013 at 18:21
  • htaccess
  • 287
  • 81
  • United States
 


Author: css-tricks Language: United States
License: Freeware
Size: 0 KB
Downloads: 20 times

 

This code is useful for multi environment setups (staging, production, etc.) it allows you to keep your htaccess files in sync while maintaining an htpasswd on your development environment or anything but the live environment.

#allows a single uri through the .htaccess password protection
SetEnvIf Request_URI /testing_uri$ test_uri

#allows everything if its on a certain host
SetEnvIf HOST ^testing.yoursite.com testing_url
SetEnvIf HOST ^yoursite.com live_url
Order Deny,Allow

AuthName Restricted Area
AuthType Basic
AuthUserFile /path/to/your/.htpasswd
AuthGroupFile /
Require valid-user

#Allow valid-user
Deny from all
Allow from env=test_uri
Allow from env=testing_url
Allow from env=live_url
Satisfy any

happy coding
comments powered by Disqus

Related Code

Countable is a JavaScript function

Passing JavaScript variables to PHP

Create Dynamic Bar Graph or Chart in php

Securimage with Image

INFORMATION_SCHEMA.TABLES

A Simple PHP Image Resize Code

How Create a Zip File Using PHP

Icon Extractor - full delphi source code

Func-In Delphi Example

Create Search and Get in The Middle String



Category

Tag Linked