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. Security headers disappear on WordPress pages
  30. Why is this line of code Wrong in every WordPress .Htaccess security article?
  31. Authentication versus Authorization
  32. How to redirect all HTTP requests to HTTPS
  33. Best collection of code for your .htaccess file [closed]
  34. Default .htaccess file for WordPress?
  35. Which one does WordPress prioritize when it comes to php.ini, wp-config and .htaccess?
  36. Security and .htaccess
  37. WordPress site hacked. Has .htaccess been hacked?
  38. htaccess problem after saving Settings
  39. Disable WordPress 3.6 idle logout / login modal window / session expiration
  40. Protecting direct access to PDF and ZIP unless user logged in (without plugin)
  41. Stop WordPress and Plugins from Overwriting .htaccess
  42. How to secure or disable the RSS feeds?
  43. How to fake a WordPress login?
  44. htaccess disable WordPress rewrite rules for folder and its contents
  45. htaccess rewrite conflict with wordpress rules and ssl
  46. htaccess https redirect from www to non-www
  47. What does a security risk in a plugin look like?
  48. Htaccess for Wordpess set on single subdomain
  49. Securing wp-admin folder – Purpose? Importance?
  50. .htaccess and 500 error, extra character added
  51. Log in from one wordpress website to another wordpress website
  52. Name-based virtual host configuration in Apache seems to cause a “500 Internal Server Error”
  53. Place static HTML files in path below WordPress page
  54. Static raw HTML page
  55. WordPress + Magento .htaccess ReWriteRule Issue (www vs. non-www)
  56. Plugin to edit htaccess file
  57. htaccess rewrite for author query string when WP is in subfolder
  58. Why “Settings->Permalinks” creates .htaccess file on nginx server?
  59. .htaccess for wordpress inside another wordpress install
  60. .htaccess file redirecting to parent directory
  61. Blog.php or how to display recent posts?
  62. Options for restricting access to wp-admin
  63. Rewrite /?rest_route=/ link to /wp-json/ without changing default permalink structure in apache
  64. Globally force SSL on all pages
  65. Serve apache 404 for missing assets rather then wp 404 template WP_Rewrites
  66. Isolating WordPress to a subfolder
  67. Remove year and month in URL using .htaccess
  68. index.php not loading in main folder of wordpress
  69. Admin-Ajax.php, SSL, Non-SSL
  70. Security error WP 4.0 + WP phpBB Bridge [closed]
  71. How to Block Access to Standard Login Flow and Comment Flow
  72. How disable SSL redirect for specific URL?
  73. WordPress site displaying 404 for any page apart from index
  74. Which ways can be used to log in to WordPress?
  75. Why does the header set X-Robots-Tag apply to all pages?
  76. Permalinks not working on second wordpress installed in a subdirect
  77. How to avoid wordpress permalink rules to inherit in a sub-folder
  78. How to change “wp-admin” to something else without search-replacing the core?
  79. Error:406 not acceptable
  80. Unable to access WP admin
  81. .htaccess Rewrite URL WordPress
  82. Move wordpress to folder without changing urls
  83. How do I authenticate WP users from a chrome extension?
  84. Rewrite rule not working
  85. A plugin changes my .htaccess file and I can’t access httpd.conf as that’s a shared server
  86. Cant block wordpress readme files
  87. Change wp-content without changing the name of the folder
  88. 404/500 error on /wp-json
  89. WordPress keeps deleting .htaccess file
  90. Correct htaccess to display page while also passing in GET parameters
  91. What is the role of .htaccess file in WordPress?
  92. Using WordPress only for the backend, and using AngularJS as a frontend
  93. Temporary .htaccess blocking is disabling WP Crons from running?
  94. Block access to wp-admin
  95. Best Way to Enable Two Step Authentication
  96. How to restrict access to wp-content, wp-includes and all sub-folders
  97. Two domains on one WordPress Installation
  98. .htaccess redirects disappeared after re-saving permalinks
  99. Protect Upload Folder Files With Ampersand Problem
  100. How have I misconfigured basic auth for my wordpress site?
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
  • Post Navigation Elementor
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • WPFacet multiple loop displaying duplicate content
  • Get the name of the template/*html file used
  • Fix: WordPress.DB.PreparedSQL.NotPrepared Plugin Check (PCP)
  • Removing unnecessary CSS and JS code from wp_head()
  • hexagonal image gallery. Am I on the right track? [closed]
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
© 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