Computer >> คอมพิวเตอร์ >  >> การเขียนโปรแกรม >> HTML

วิธีจำกัดการเข้าถึงไดเรกทอรีผู้ดูแลระบบ WordPress

ปัจจุบัน WordPress ขับเคลื่อนเว็บไซต์มากกว่า 60 ล้านเว็บไซต์ ซึ่งทำให้เป็น CMS ที่ได้รับความนิยมสูงสุด เนื่องจากความนิยมดึงความสนใจทั้งดีและไม่ดี ไซต์ WordPress มักจะประสบกับความพยายามแฮ็ค 90000 ทุกนาทีของวัน เมื่อพูดถึงความปลอดภัยของไซต์ น่าเสียดายที่ไม่มีสัญลักษณ์แสดงหัวข้อย่อยสีเงินที่จะให้การรักษาความปลอดภัยในทุกด้าน ค่อนข้างต้องทำหลายสิ่งหลายอย่าง ใช้การรักษาความปลอดภัยที่แบบอักษรต่างๆ เพื่อให้แน่ใจว่าไซต์ของพวกเขาปลอดภัยจากแฮกเกอร์ กระบวนการเพิ่มชั้นการป้องกันที่แตกต่างกันเรียกว่าการป้องกันชั้น ก่อนหน้านี้ เราได้พูดถึงมาตรการป้องกัน เช่น การใช้การรับรองความถูกต้อง HTTP, การตรวจสอบสิทธิ์แบบสองปัจจัย, การใช้ชื่อผู้ใช้และรหัสผ่านที่รัดกุม วันนี้ เรากำลังเรียนรู้วิธีป้องกันอีกวิธีหนึ่ง ซึ่งคุณจะจำกัดการเข้าถึงไดเรกทอรีผู้ดูแลระบบ WordPress

ไดเร็กทอรีผู้ดูแลระบบ WordPress เป็นที่ที่ไฟล์ WordPress หลักอยู่ ไฟล์ในนั้นทำให้ผู้ใช้เช่นคุณดำเนินการฟังก์ชันการดูแลระบบต่างๆ ได้ ตัวอย่างเช่น เมื่อคุณพยายามเข้าสู่ระบบแดชบอร์ด WordPress จะตรวจสอบว่าข้อมูลรับรองที่คุณให้มานั้นถูกต้องหรือไม่ หรือว่าคุณเป็นผู้ดูแลระบบหรือผู้ร่วมให้ข้อมูลทั่วไปที่มีการเข้าถึงไซต์อย่างจำกัด ไฟล์ในโฟลเดอร์ wp-admin ทำให้ WordPress สามารถทำหน้าที่เหล่านี้ได้

เมื่อแฮกเกอร์เข้าถึงไซต์ของคุณ พวกเขาอาจแก้ไขไฟล์เพื่อเพิ่มเติมแรงจูงใจของตนเอง พวกเขาอาจเริ่มกำหนดว่าใครสามารถเข้าถึงไซต์และใครไม่ได้ มีความเป็นไปได้จริงที่พวกเขาอาจปิดกั้นผู้ดูแลระบบและเจ้าของเว็บไซต์ คุณอาจสูญเสียการเข้าถึงไซต์ของคุณเอง นี่คือเหตุผลที่จำเป็นต้องระมัดระวังไว้ก่อน การจำกัดการเข้าถึงไดเรกทอรีผู้ดูแลระบบ WordPress จะจำกัดไม่ให้แฮกเกอร์เข้ายึดเว็บไซต์ของคุณ

วิธีที่ง่ายที่สุดในการอธิบายว่าข้อจำกัดทำงานอย่างไรผ่านการเปรียบเทียบ หากเว็บไซต์ของคุณเป็นบ้านและประตูบ้านคือไดเร็กทอรีผู้ดูแลระบบ WordPress ของคุณ ตอนนี้ถ้าคุณส่งยามที่ประตู บ้านของคุณก็จะปลอดภัยยิ่งขึ้น (อ่านที่ไซต์) เจ้าหน้าที่รักษาความปลอดภัยมีหน้าที่ตรวจสอบ (อ่านที่อยู่ IP) ของผู้มาเยี่ยมทุกคน จากนั้นอนุญาตหรือปฏิเสธการเข้าถึงบ้าน (เช่น เว็บไซต์) ในบทความนี้ เราจะแสดงวิธีจำกัดการเข้าถึงไดเรกทอรีผู้ดูแลระบบ WordPress โดยใช้ที่อยู่ IP โดยพื้นฐานแล้วหมายความว่าคุณจะปิดกั้นเฉพาะที่อยู่ IP ปลอมเฉพาะจากการเข้าถึงไดเรกทอรีผู้ดูแลระบบของไซต์ WordPress ของคุณ

ก่อนที่เราจะเริ่มต้น สิ่งสำคัญคือต้องทราบว่าคุณต้องตรวจสอบให้แน่ใจว่าที่อยู่ IP ของคุณเป็นแบบคงที่ หากคุณไม่แน่ใจเกี่ยวกับที่อยู่ IP ของคุณ เราขอแนะนำให้คุณค้นหาโดย Google หรือพูดคุยกับผู้ให้บริการอินเทอร์เน็ตของคุณ

จำกัดการเข้าถึงไดเรกทอรีผู้ดูแลระบบ WordPress:

ในการเริ่มต้น ก่อนอื่นคุณต้องดาวน์โหลดไฟล์ .htaccess จากตัวจัดการไฟล์ของคุณ ทำตามขั้นตอนด้านล่าง:

เข้าสู่ระบบบัญชีโฮสต์เว็บของคุณ และไปที่หน้าชื่อ cPanel . ที่นั่นคุณควรจะพบตัวเลือกสำหรับ ตัวจัดการไฟล์ . เลือกและหน้าจะเปิดขึ้นซึ่งจะมีลักษณะดังนี้:

วิธีจำกัดการเข้าถึงไดเรกทอรีผู้ดูแลระบบ WordPress

ขั้นตอนที่ 2: This is a typical file manager page. On the left-hand side, there are a bunch of folders. Select public_html, and you’d see a drop-down.

วิธีจำกัดการเข้าถึงไดเรกทอรีผู้ดูแลระบบ WordPress

Step 3: In the drop down there will a folder called wp-admin . You’ll find a .htaccess file in this folder. You’d notice that unlike other files in the directory, .htaccess has no extension like .html or .txt. or PHP.

Step 4: To download the .htaccess file all you need to do is download the file using a download button on the File Manager page. It should look something like the image below:

วิธีจำกัดการเข้าถึงไดเรกทอรีผู้ดูแลระบบ WordPress

Sometimes .htaccess is hidden and may not appear in the public_html folder. When that’s the case, what you need to do is go back to the cPanel , and click on File Manager . A popup will appear where you’ll have to select ‘Show Hidden Files’.

วิธีจำกัดการเข้าถึงไดเรกทอรีผู้ดูแลระบบ WordPress

In case, you find out that your website does not have a .htaccess file, you’ll need to create a new one.

After you have downloaded the .htaccess file, open it. It should look something like the picture below:

วิธีจำกัดการเข้าถึงไดเรกทอรีผู้ดูแลระบบ WordPress

Step 5: At the end of the .htaccess file, add the following code:

order deny, allow 

allow from your.IP.address 

deny from all 

Note: Place the IP address that you want to blacklist instead of ‘IP.address.1’ and ‘IP.address.2’.

Step 6: After you are done, you will need to upload the file in the public_html directory in the File Manager. There should be an Upload option in the File Manager page.

วิธีจำกัดการเข้าถึงไดเรกทอรีผู้ดูแลระบบ WordPress

After you upload the file, the IP’s you mentioned will be blocked. When these IP addresses try to access your site, they’ll see a ‘403 Forbidden’ error on the page.

Make sure that the .htaccess file you modified was from the ‘wp-admin’ directory and not the root directory (i.e. public_html) of your WordPress. There is a .htaccess file in the root directory, and we are not making any changes in that. If by mistake, you modified the .htaccess file in the ‘wp-admin’ directory, then all visitor to your site will be blocked. You don’t want that. Therefore we’d recommend you to be very careful.

There is one issue that may crop up when you limit access to WordPress admin directory using IP. It breaks the front-end Ajax functionality. This particular functionality enables web pages to show real-time changes. For instance, you may be using a plugin that allows Twitter feed on your site. Every time you tweet something, it automatically appears on the site. You don’t need to reload the page to see the tweet. This is possible due to the Ajax functionality.

To avoid breaking the front-end Ajax functionality, you’ll need to find out if any of your plugins use Ajax in the front end. If yes, then you’ll have to add the following code to your .htaccess file from the wp-admin directory.

<Files admin-ajax.php> 

order allow, deny 

allow from all 

satisfy any </Files>

And that’s it.

Over to You

In order to limit access to WordPress admin directory, you’d have to have a bit of knowledge about WordPress files. We hope that after reading this post, your site will be a bit more secure than it was before. Please contact us if you have any queries or feedback. And thanks for reading.