wordpress中使用 htaccess要注意的几点
在Apache2中, 可以使用htaccess 给一个特定目录下的路径提供特定的配置. wordpress中把rewrite 规则写入到htaccess中的来实现permanent links.
Apache2中的htaccess默认是没有激活的. 对于一个Directory, 我们需要提供 AllowOverride All来激活htaccess.
``` {.EnlighterJSRAW data-enlighter-language="null"}
Other options.
wordpress后台管理在设置permalink时, 需要具有写 .htaccess文件的权限. 我们可以把wordpress目录的所有者改为apache2进程的用户.
``` {.EnlighterJSRAW data-enlighter-language="null"}
$ sudo chown www-data /var/www/wordpress/
$ cat /var/www/wordpress/.htaccess
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wordpress/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]
</IfModule>
参考资料
- apache2的官方文档: https://httpd.apache.org/docs/current/howto/htaccess.html