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’, )); }

Change wp-content without changing the name of the folder

Strip the preceeding forward slashes from your rules: Example (incorrect) RewriteRule ^/css/(.*) /wp-content/themes/themename/css/$1 [QSA,L] Example (correct) RewriteRule ^css/(.*) wp-content/themes/themename/css/$1 [QSA,L] All rules (correct) # BEGIN WordPress <IfModule mod_rewrite.c> RewriteRule ^/index\.php$ – [L] RewriteRule ^css/(.*) wp-content/themes/themename/css/$1 [QSA,L] RewriteRule ^js/(.*) wp-content/themes/themename/js/$1 [QSA,L] RewriteRule ^img/(.*) wp-content/themes/themename/img/$1 [QSA,L] RewriteRule ^font/(.*) wp-content/themes/themename/font/$1 [QSA,L] RewriteRule ^plugins/(.*) wp-content/plugins/$1 [QSA,L] RewriteCond %{REQUEST_FILENAME} !-f … Read more

Cant block wordpress readme files

You don’t really need these: Redirect 404 /install.php Redirect 404 readme.html To block readme.html you do this: <files readme.html> order allow,deny deny from all </files> For other kind of files you need do the same just change file name in code.

Rewrite rule not working

If this address already gets traffic (from inbound links etc.) why don’t you try a good old fashioned redirect like this: Redirect 301 /sca/project_0 http://www.yourdomain.com/sca?urn=project_0 # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ – [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> Or use the 301 redirect in … Read more