跳至內容
工具

WordPress .htaccess Generator

The rules WordPress needs, plus the hardening rules it does not ship with

在你的瀏覽器裡執行。什麼都不會被上傳。

Core
Redirects
Hardening
.htaccess

Apache only. If your host runs nginx (many managed WordPress hosts do), .htaccess is ignored entirely and these rules must go in the server config instead.

關於WordPress .htaccess Generator

Generate a WordPress .htaccess file: the default rewrite rules, forced HTTPS, www-to-apex redirects, wp-login brute-force blocking, XML-RPC blocking, and wp-config protection. Copy it out and paste it in.

FAQ

常見問題

為什麼我自訂的 .htaccess 規則不見了?

因為它們寫在「# BEGIN WordPress」區塊裡面。每次你儲存永久連結設定時,WordPress 都會重寫它 BEGIN 與 END 標記之間的所有內容,悄悄刪掉你加在那裡的任何東西。自訂規則必須放在那個區塊「上面」。

封鎖 xmlrpc.php 能擋住暴力破解攻擊嗎?

它關上一道門,但不是全部。攻擊者仍然可以直接打 wp-login.php。如果你用到的東西都不需要它,封鎖確實值得——但要注意,WordPress 行動 App 和 Jetpack 都會用到它。

我的主機跑的是 nginx。.htaccess 有用嗎?

沒用。nginx 完全忽略 .htaccess——那個檔案放在那裡什麼都不會做。許多代管型 WordPress 主機跑的都是 nginx,所以如果你的規則看起來完全沒有效果,先確認你實際上是在哪種伺服器上,再去除錯規則本身。