{"id":4378,"date":"2009-10-11T05:59:04","date_gmt":"2009-10-11T12:59:04","guid":{"rendered":"http:\/\/css-tricks.com\/?page_id=4378"},"modified":"2009-10-11T05:59:04","modified_gmt":"2009-10-11T12:59:04","slug":"allow-single-url","status":"publish","type":"page","link":"https:\/\/css-tricks.com\/snippets\/htaccess\/allow-single-url\/","title":{"rendered":"Allow Single URL Through .htaccess Password Protection"},"content":{"rendered":"

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.<\/p>\n

#allows a single uri through the .htaccess password protection\r\nSetEnvIf Request_URI \"\/testing_uri$\" test_uri\r\n\r\n#allows everything if its on a certain host\r\nSetEnvIf HOST \"^testing.yoursite.com\" testing_url\r\nSetEnvIf HOST \"^yoursite.com\" live_url\r\nOrder Deny,Allow\r\n\r\nAuthName \"Restricted Area\"\r\nAuthType Basic\r\nAuthUserFile \/path\/to\/your\/.htpasswd\r\nAuthGroupFile \/\r\nRequire valid-user\r\n\r\n#Allow valid-user\r\nDeny from all\r\nAllow from env=test_uri\r\nAllow from env=testing_url\r\nAllow from env=live_url\r\nSatisfy any<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"

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 […]<\/p>\n","protected":false},"author":3,"featured_media":0,"parent":3826,"menu_order":0,"comment_status":"open","ping_status":"closed","template":"page-snippet.php","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"sig_custom_text":"","sig_image_type":"featured-image","sig_custom_image":0,"sig_is_disabled":false,"inline_featured_image":false,"c2c_always_allow_admin_comments":false,"footnotes":""},"tags":[],"acf":[],"jetpack-related-posts":[{"id":4232,"url":"https:\/\/css-tricks.com\/snippets\/htaccess\/password-protect-folders\/","url_meta":{"origin":4378,"position":0},"title":"Password Protect Folder(s)","date":"September 25, 2009","format":false,"excerpt":"Put in .htaccess file in the directory you are trying to protect: AuthType Basic AuthName \"This Area is Password Protected\" AuthUserFile \/full\/path\/to\/.htpasswd Require valid-user Ideally, the .htpasswd file will be not in a public facing directory. Put this in there: chriscoyier:$apr1$O\/BJv...$vIHV9Q7ySPkw6Mv6Kd\/ZE\/ That is just a sample, you can create the\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":195626,"url":"https:\/\/css-tricks.com\/snippets\/htaccess\/denying-allowing-access\/","url_meta":{"origin":4378,"position":1},"title":"Denying and Allowing Access","date":"February 11, 2015","format":false,"excerpt":"Deny except from specific IPs Order deny,allow Deny from All Allow from xxx.xxx.xxx.xxx Allow from xxx.xxx.xxx.xxy Allow except from specific IPs Order deny,allow Allow from All Deny from xxx.xxx.xxx.xxx Deny from xxx.xxx.xxx.xxy","rel":"","context":"With 1 comment","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":4234,"url":"https:\/\/css-tricks.com\/snippets\/php\/find-the-full-path-to-a-file\/","url_meta":{"origin":4378,"position":2},"title":"Find the Full Path to a File","date":"September 25, 2009","format":false,"excerpt":"Save the file as fullpath.php Upload to the folder you'd like to know the full path to Go to http:\/\/www.yoursite\/lots\/of\/folders\/fullpath.php You'd might be surprised what shows up. Sometimes you need more than just \/lots\/of\/folders\/ as your full path to a file (e.g. .htpasswd). This script will allow you to see\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":163734,"url":"https:\/\/css-tricks.com\/snippets\/htaccess\/serve-svg-correct-content-type\/","url_meta":{"origin":4378,"position":3},"title":"Serve SVG with the Correct Content Type","date":"February 22, 2014","format":false,"excerpt":"If you are trying to use SVG like or as a CSS background-image, and the file is linked to correctly and everything seems right, but the browser isn't displaying it, it might be because your server is serving it with an incorrect content-type. Add this to your .htaccess file at\u2026","rel":"","context":"With 18 comments","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":195624,"url":"https:\/\/css-tricks.com\/snippets\/htaccess\/force-https\/","url_meta":{"origin":4378,"position":4},"title":"Force HTTPS","date":"February 11, 2015","format":false,"excerpt":"RewriteEngine on RewriteCond %{HTTPS} !on RewriteRule (.*) https:\/\/%{HTTP_HOST}%{REQUEST_URI} If you have a proxy in front of your server performing TLS termination: RewriteCond %{HTTP:X-Forwarded-Proto} !https RewriteRule (.*) https:\/\/%{HTTP_HOST}%{REQUEST_URI}","rel":"","context":"With 4 comments","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":152212,"url":"https:\/\/css-tricks.com\/lodge\/learn-jquery\/16-intro-ajax\/","url_meta":{"origin":4378,"position":5},"title":"#16: Intro To Ajax","date":"October 7, 2013","format":false,"excerpt":"Ajax ranks pretty high up there on the biggest reasons to use jQuery. Not only does jQuery fix the cross-browser issues, it makes the syntax very easy to use and understand. In this video we take a stab at explain what Ajax is at all. We look at a form\u2026","rel":"","context":"With 1 comment","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/pages\/4378"}],"collection":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/comments?post=4378"}],"version-history":[{"count":2,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/pages\/4378\/revisions"}],"predecessor-version":[{"id":4380,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/pages\/4378\/revisions\/4380"}],"up":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/pages\/3826"}],"wp:attachment":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/media?parent=4378"}],"wp:term":[{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/tags?post=4378"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}