我有本地服务器,我正在使用Composer运行WordPress。
数据库从我的本地迁移到 AWS RDS 后,永久链接改变了它的行为:现在标签的开头有"index.php",例如:
http://example.com/索引.php/页面名称
此外,在wp-admin->Settings->Permalinks中,结构现在是自定义的:
/index.php/%year%/%monthnum%/%day%/%postname%/
有关我的本地服务器的详细信息:
- Xubuntu 18
- 阿帕奇2
- 允许覆盖所有
/
和var/www/
- 它在作曲家上,带有自定义目录(WP内容与WP核心分开(
-
.htaccess:
# BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase /project/public/wp/ RewriteRule ^index.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /project/public/wp/index.php [L] </IfModule> # END WordPress
我尝试过的:
http://dejanjanosevic.info/remove-index-php-permalink-in-wordpress/
http://derekmolloy.ie/remove-index-php-from-your-wordpress-url/
- 更新永久链接
- 更新作曲家
- 把我的灵魂卖给撒旦
结果如何?
修改 .htaccess 没有任何效果 - 只是以 404 结尾,唯一有效的链接仍然是包含/index.php/
的链接。从WordPress更新永久链接具有相同的结果。
我在这里没有想法了。
我知道了。
对于任何寻求解决同一问题的人,这里有指南:
- 将 wp-admin 中的永久链接设置更改为漂亮的永久链接
- 在 Apache 中安装 mod_rewrite 模块
-
最重要的部分,在etc/apache/apache2.conf中(请注意,您必须更改文件夹的名称(:
<Directory /> Options FollowSymLinks AllowOverride All Require all denied </Directory> <Directory /usr/share> AllowOverride None Require all granted </Directory> <Directory /var/www/> Options Indexes FollowSymLinks AllowOverride All Require all granted </Directory> #<Directory /srv/> # Options Indexes FollowSymLinks # AllowOverride None # Require all granted #</Directory> <Directory "/var/www/html/NAME_OF_YOUR_PROJECT_FOLDER"> Options FollowSymLinks AllowOverride All </Directory>*
- 重启 apache