Using “wordpress_logged_in” to restrict direct access to uploads folder in 2021

Check to see if a person is logged in: <IfModule mod_rewrite.c> RewriteCond %{REQUEST_FILENAME} (.*) RewriteCond %{HTTP_COOKIE} !wordpress_logged_in_([a-zA-Z0-9_]*) [NC] RewriteRule .* – [F,L] </IfModule> The same applies as it did 10 years ago. This code in .htaccess doesn’t have anything to do with how WordPress might be setting cookies. And this does not “check to see … Read more

What is the role of .htaccess file in WordPress?

The .htaccess file is not actually required for WordPress to “work”. However, it is required if you wish to create a more user-friendly URL structure (ie. anything other than “plain” permalinks, as Jack suggests). This is also why the default WordPress .htaccess file surrounds the directives in an <IfModule mod_rewrite.c> container. It “works” if “mod_rewrite” … Read more

404/500 error on /wp-json

Are you trying to use that function without first initiating it in an action? It should be done like so: add_action( ‘rest_api_init’, ‘add_custom_users_api’); function add_custom_users_api() { register_rest_route( ‘route’, array( ‘methods’ => ‘GET’, ‘callback’ => ‘function’, )); }