Leveraging AI to Supercharge Your WordPress Business Website
In today’s competitive digital landscape, every business website needs an edge to...
14.Jun.2022 | Code Snippets, Wordpress
Prevent files from being directly accessed unless the user is logged in by pasting the following code into your .htaccess file. This is useful if you have a secure area on your website and you want to prevent secure files being shared via direct link.
You can specify file types by separating with a pipe symbol. Edit as required.
Paste the following code after “# END WordPress”.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_COOKIE} !.*wordpress_logged_in.*$ [NC]
RewriteCond %{REQUEST_URI} ^(.*?/?)wp-content/uploads/.*\.(?:pdf|txt|rtf|xlsx?|docx?|mp3|mp4|mov)$ [NC]
RewriteRule . http://%{HTTP_HOST}%1/wp-login.php?redirect_to=%{REQUEST_URI} [L,QSA]
</IfModule>
Share
In today’s competitive digital landscape, every business website needs an edge to...
WordPress has come a long way since its humble beginnings in 2003....
In the ever-evolving landscape of website development, staying ahead of the curve...
Need a bespoke WooCommerce site with dynamic content for two types of visitor? For example, this is from a recent...
This snippet of PHP can come in handy for removing the empty spaces in a string. Here is it being...
A quick way to remove empty p tags from custom shortcodes in Wordpress. <?php add_filter("the_content", "the_content_filter"); function the_content_filter($content) { $block...