Allow logged in users who doesn’t belong to whitelisted ips

Simple & Fast but not 100% secure method: This method is not 100% secure, but for most users (like 99%), it’ll work. Here, basically you’ll use a .htaccess file inside the restricted directory, say: /var/www/html/link with the following CODE: SetEnvIf Cookie “^.*wordpress_logged_in.*$” WP_LOGGED_IN=maybe Order allow,deny Require all granted # Our Network #Allow from ip-address/22 #Allow … Read more

htaccess 301 redirect http to https doesn’t work

You’ve put the redirect code in the wrong place. It needs to go before the # BEGIN WordPress section. By placing the redirect code after the WordPress front-controller it will never be processed unless the request is for a physical file. However, your first attempt is not correct (it’s missing the check for HTTPS), so … Read more

Cleanup URL for a custom page in wordpress

You can do this with the internal rewrite system, which is parsed in php, not htaccess. First, add the rule. This assumes you have created a root page under Pages with the slug dictionary. function wpd_dictionary_rewrite(){ add_rewrite_tag( ‘%dictionary_word%’, ‘([^/]+)’ ); add_rewrite_rule( ‘^dictionary/([^/]+)/?$’, ‘index.php?pagename=dictionary&dictionary_word=$matches[1]’, ‘top’ ); } add_action( ‘init’, ‘wpd_dictionary_rewrite’ ); This code would go in … Read more

Rewrite rule to load images from production does nothing

RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . index.php [L] # If images not found on development site, load from production RewriteCond %{REQUEST_URI} ^/wp-content/uploads/[^\/]*/.*$ RewriteRule ^(.*)$ https://www.example.com/$1 [QSA,L] The problem here is that “If images not found on development site” then the request has already been rewritten to index.php by the preceding RewriteRule (WordPress front-controller), … Read more

Deny access to a path (give 403 or 404 response)

# this give internal server error throughout site: <Files ~ “/users/”> Header set X-Robots-Tag “noindex, nofollow” </FilesMatch> This would give an “internal server error” (500 response) because you’ve used </FilesMatch> to close the <Files> section. It should be </Files>. But as you suggested, this won’t work anyway, as the <Files> directive matches real files only, … Read more

Site searches by Python for non-existent assets

What are the python searches? Are they like bad bots? Most probably just “bad bots” searching for potential vulnerabilities. How do I block or prevent them? Well, you are already serving a 404 by the sounds of it, so it’s really a non-issue. However, you can prevent the request from going through WordPress by blocking … Read more

Remove / from www.example.com/ [closed]

This isn’t a WordPress thing, this is a browser/HTTP thing. Firefox may be showing the / as part of a setting, but example.com and example.com/ are the same URL. This Q on webmasters goes into more detail as to why this is the case: https://webmasters.stackexchange.com/questions/35643/is-trailing-slash-automagically-added-on-click-of-home-page-url-in-browser