Skip to main content

Protect wordpress Websites With .htaccess

FL Faysal

FL Faysal

WordPress Web Designer, Security Expert & Trainer

April 05, 2024 • 2 min read • 2 views
Protect wordpress Websites With .htaccess
Protect wordpress Websites With .htaccess   আমাদের ওয়ার্ডপ্রেসের ওয়েবসাইটে রুট ডাইরেক্টরি এর ভিতরে অনেক সেনসিটিভ একটা ফাইলের নাম হল .htaccess. আমরা অনেকে ওয়ার্ডপ্রেস ওয়েবসাইট ডিজাইন করি এবং প্লাগিন নিয়ে কাজ করি কিন্তু আমাদের .htaccess ফাইলটির কথা কেউ ভাবি না অথবা অনেকেই চিনি না। আজকে আমরা .htaccess এর মাধ্যমে ওয়ার্ডপ্রেসের বিভিন্ন ধরনের সিকিউরিটি কিভাবে কনফার্ম করা যায় তা দেখব। " আজকে আমরা .htaccess এর মাধ্যমে ওয়ার্ডপ্রেসের বিভিন্ন ধরনের সিকিউরিটি কিভাবে কনফার্ম করা যায় তা দেখব। 1. Configuring the .htaccess file " আমাদের ডিফল্ট ওয়ার্ডপ্রেসের দেওয়া .htaccess কোডগুলো নিচে দেওয়া হল। প্রথমে আমাদের কাজ ওয়েবসাইটের .htaccess ফাইল টি এডিট করে এই কোডগুলো বসিয়ে দেওয়া: # 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> # END WordPress " 2. Protect .htaccess "# Protect .HTACCESS <Files ~ “^.*\.([Hh][Tt][Aa])”><Files ~ “^.*\.([Hh][Tt][Aa])”> order allow,deny deny from all satisfy all </Files>" 3. Protect wp-config.php " আমাদের ওয়ার্ডপ্রেস ওয়েব সাইটে wp-config.php ফাইলে আমাদের ওয়েবসাইটে বিভিন্ন ইনফর্মেশন স্টোর করা থাকে। তাই এই ডাটাগুলো যাদের কেউ access না করতে পারে নিচের কোডগুলো বসাতে হবে: # WP-CONFIG BLOCK <Files wp-config.php> order allow,deny deny from all </Files> "   4. No directory browsing: It will block browsing directories " আমাদের ওয়ার্ডপ্রেস ওয়েব সাইটে ডাইরেক্টরি ইনডেক্সিং যদি অফ করার না থাকে যে কেউ আমাদের ওয়েবসাইটের বিভিন্ন ফাইল থিম প্লাগিন সম্পর্কে ইনফরমেশন জেনে যাবে। তাই নিচের কোডগুলো বসাতে হবে : # directory browsing block Options All -Indexes " ● Check directory indexing is blocked : https://hackertarget.com/wordpress-security-scan/ 5. Disable XMLRPC.PHP " XMLRPC ডিজেবল করা না থাকলে বিভিন্ন ধরনের এসকিউএল ইনজেকশন এবং কুকি হাইজাকিং হতে পারে। ● Block WordPress xmlrpc.php requests Check your domain.com/xmlrpc.php (Its open normally for attacks) " " নিচের কোডগুলো ব্যবহার করে আমরা সহজেই XMLRPC ডিজেবল করে রাখতে পারি: # Disable XMLRPC.PHP <Files xmlrpc.php> order deny,allow deny from all </Files> " 6. Disable scanners in Your Website: " বিভিন্ন স্ক্যানার আমাদের ওয়েবসাইটে বিভিন্নভাবে Vulnerability যাতে বের না করতে পারে তাই ওয়েবসাইট স্ক্যানিং ডিজেবল করার জন্য নিচের কোডগুলো ব্যবহার করতে হবে: # BEGIN block author scans RewriteEngine On RewriteBase / RewriteCond %{QUERY_STRING} (author=\d+) [NC] RewriteRule .* - [F] # END block author scans " 7. Block Suspicious IP " যদি কোন আইপি আমাদের ওয়েবসাইটে বিভিন্ন ধরনের অ্যাটাক পরিচালনা করতে চায় তাহলে আমরা নির্দিষ্ট কোনো একটি আইপি ব্লক করে দিতে পারি নিচের কোডগুলো মাধ্যমে: # IP block order allow, deny deny from (IP) allow from all " "# IP block Order Allow,Deny Allow from all Deny from 1.186.48.58, 65.30.114.186, 69.143.222.95" 8. Individual File Protection " অনেক সময় আমার নির্দিষ্ট কোন ফাইলের এক্সপ্রেস বন্ধ করার জন্য নিচের কোডগুলো ব্যবহার করতে পারি: # Protect the .htaccess <files .htaccess=""""> order allow,deny deny from all </files> " 9. wp-content Access Prevention " ওয়ার্ডপ্রেসের wp-content ডাইরেক্টরি অনেক গুরুত্বপূর্ণ। কেউ যাতে কোন ম্যালিশিয়াস কনটেন্ট আমাদের wp-content ডিরেক্টরি তে না ঢোকাতে পারে তাই আমার নিচের কোডগুলো ব্যবহার করতে পারি: > create a new .htaccess file in wp-content directory & put the code there # wp-content access deny Order deny,allow Deny from all <Files ~ “.(xml|css|jpe?g|png|gif|js)$”> Allow from all </Files>"   10. Uploads Directory Access Blocking " আমাদের আপলোড ফোল্ডারে কেউ যাতে কোনো ধরনের ফাইল ইনজেকশন অথবা টেম্পারিং না করতে পারে তাই আমরা নিচের কোডগুলো ব্যবহার করতে পারি: Disable PHP and Other Files Upload on (wp-content/uploads) folder: " Disable PHP and Other Files Upload on (wp-content/uploads) folder: " > create a new .htaccess file in wp-content/uploads directory & put the codes there: # uploads directory access deny <Files *.php> deny from all </Files> # Block executables <FilesMatch ""\.(php|phtml|php3|php4|php5|pl|py|jsp|asp|html|htm|shtml|sh|cgi|suspected)$""> deny from all </FilesMatch> " " .HTACCESS এ এই সমস্ত কোডগুলো Injection এর মাধ্যমে আমরা খুব সহজে ওয়ার্ডপ্রেসের বিভিন্ন ধরনের VULNERABILITY দূর করতে পারি। "
FL Faysal
Written by

FL Faysal

WordPress designer, security specialist, and trainer. I build fast, secure websites and share practical tutorials to help others learn web development and freelancing.