Wednesday, April 24, 2024

WordPress固定链接的htaccess文件设置

WordPress设置固定链接时,如果提示需要设置.htaccess文件,可使用文本编辑器新建一个文本,内容如下:

# BEGIN WordPress

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L] </IfModule>

# END WordPress

直接保存为.htaccess文件,上传到网站的WordPress目录中即可(与index.php同目录)。

重要提示:
上文代码中第三行的 /blog/和第六行的 /blog/index.php请根据你自己WordPress的实际安装目录进行修改,否则会出错。

One comment

  1. 这个设置的确比较头痛,如果有什么插件可以实现就好了。

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.