Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

Basic Auth .htaccess on wp-login, but allow logout from woocommerce

From the answer in Password protect a specific URL, we can reverse the condition. To quote his answer,

You should be able to do this using the combination of mod_env and the
Satisfy any directive. You can use SetEnvIf to check against the
Request_URI, even if it’s not a physical path. You can then check if
the variable is set in an Allow statement. So either you need to log
in with password, or the Allow lets you in without password:

# Do the regex check against the URI here, if match, set the "require_auth" var
SetEnvIf Request_URI ^/shop/my-account/customer-logout/ require_auth=false

# Auth stuff
AuthUserFile /var/www/htpasswd
AuthName "Password Protected"
AuthType Basic

# Setup a deny/allow
Order Deny,Allow
# Deny from everyone
Deny from all
# except if either of these are satisfied
Satisfy any
# 1. a valid authenticated user
Require valid-user
# or 2. the "require_auth" var is NOT set
Allow from env=!require_auth

Related Posts:

  1. Blocking access to wp-login via htaccess not working
  2. Attach to wp-login.php and xmlrpc.php
  3. Improve wordpress security by hiding non public resources
  4. Does this .htaccess security setting really work?
  5. Change Login URL Without Plugin
  6. File and directory permissions
  7. adding rewrite rules in .htaccess
  8. Using “wordpress_logged_in” to restrict direct access to uploads folder in 2021
  9. WordPress URL/Folder ReWrite using Htaccess
  10. Which WordPress scripts need to be executable for a fresh installation?
  11. XMLRPC filtering through htaccess not working
  12. Restricting user login by IP address
  13. WordPress: Adding Security
  14. How do I test to ensure that my wp-config file is protected?
  15. WordPress not seeing .htaccess rules
  16. Rules in .htaccess only if the requested URL is /wp-admin
  17. Disable directory browsing of uploads folder
  18. Strange behaviour of is_user_logged_in() and get_current_user_id()
  19. Where is the php file, that does the checks for login information?
  20. Selectively Disabling PHP via .htaccess in Root Directory
  21. Should I prevent access to .htaccess and wp-config.php files?
  22. Blocking wp-login in HTACCESS has also blocked password protected pages
  23. Using htaccess to prevent spam through wp-comments-post.php
  24. how to add security questions on wp-registration page and validate it
  25. How can I create a private site that is inaccessible from the outside?
  26. Restrict Content for only Contributors via .htaccess
  27. Allowing access to certain WordPress created pages or posts with htaccess / htpasswd
  28. Why ‘Authorization Required’ is coming on wordpress login
  29. Why is this line of code Wrong in every WordPress .Htaccess security article?
  30. htaccess rewrite conflict with wordpress rules and ssl
  31. Options for restricting access to wp-admin
  32. Remove year and month in URL using .htaccess
  33. Unable to access WP admin
  34. Move wordpress to folder without changing urls
  35. Using WordPress only for the backend, and using AngularJS as a frontend
  36. Two domains on one WordPress Installation
  37. Protect Upload Folder Files With Ampersand Problem
  38. .htaccess and WordPress Admin Bar
  39. How to Redirect huge numbers of URLs to another URLs?
  40. Struggling with add_rewrite_rule
  41. Giving WordPress its own subdirectory – nginx
  42. Cannot mask WordPress page URL using .htaccess
  43. need a help for modify .htaccess rule [closed]
  44. How can I make an htaccess file on a Mac? [closed]
  45. WordPress overrides custom 404 page with it’s own
  46. New installation can’t be found due to htaccess of the original non-WordPress site
  47. Fixing custom 404 pages broken by WordPress in a subdirectory
  48. Case insensitive header params for API request
  49. I can’t access the admin panel links as I click it shows 403 error
  50. 301 Redirect domain Sub-folders to Subdomain subfolder
  51. Drawbacks to using Options -Indexes
  52. How to hide login form if basic authentication fails?
  53. Override 404 page with htaccess
  54. Htaccess Rewrite reverts to default .htaccess file
  55. what could cause the htaccess file to be modified?
  56. change permalink structure with htaccess without SEO impact
  57. How to Change The WordPress Login URL Without Plugin
  58. .htaccess rules for blocking bots with an extra condition
  59. Site in subfolder – all pages work except home
  60. Can’t upload .htaccess after editing in notepad
  61. Directing subdomain to main domain and keeping the subdomain format with .htaccess
  62. Remove /sites/25/ from image URLS
  63. How disable canonical redirect wp-signup
  64. Redirect old domain with query paramaters
  65. Forcing HTTPS with WordPress on AWS
  66. WordPress Example Code for Blocking Referrer Spam
  67. How could a .htaccess with authentication suddenly appear or change?
  68. htaccess problem not being able to overwrite previous rules
  69. wordpress blog displaying blank pages [closed]
  70. Relative links stop working after moving wordpress site from hosting to localhost
  71. WordPress site blacklisted by Google about .htaccess [closed]
  72. How to fix .htaccess corrupted
  73. Protect wp-login, but get an internal server error
  74. Cannot access subdirectory subpages
  75. How can I create a smarter .htaccess file that will add a directory?
  76. WP Codex answer incomplete? Put WP in subdirectory. .htaccess change required
  77. All navigation links on website redirect to same page
  78. WordPress is removing trailing slash
  79. How to allow access based on the user meta flag
  80. Htaccess file reset automatically how to fix this issue
  81. Clone WordPress for testing on localhost (with Fiddler)
  82. Force a 403 response to xml file in WordPress
  83. Redirect files in uploads directory if WordPress user not logged in
  84. Redirect wordpress site to www from non www on wordpress server
  85. Redirect after login when WordPress in subdirectory
  86. Leverage browser caching
  87. WordPress URL not working?
  88. How to direct users to a subcatalog
  89. How to block wordpress admin by htaccess
  90. htaccess conflict between WordPress and password protected subdirectory
  91. Using subdomain as primary domain
  92. Add-on domain works in WordPress but links still lead to subdomain
  93. In a subdomain network, what .htaccess settings can I use to have WP ignore requests to one subdomain?
  94. register_post_type and register taxonomy and htaccess
  95. htaccess rule to ignore specific subdomain [closed]
  96. WordPress redirection
  97. Home page returns 404
  98. Browser Caching .htaccess
  99. FilesMatch in htaccess
  100. Are there any negative impact if access to directories were accidently denied?
Categories htaccess Tags .htaccess, authentication, security, wp-login-form
Widgets are not displaying in my theme
Link with password is not sent to the new user

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress