php - 所有链接中的奇怪 WordPress index.php
问题描述
我之前安装了几个 WordPress 服务器,但这是我第一次遇到这个问题,所有链接的 URL 中都必须有 'index.php'(即 test.com/games 而不是 test.com/index.php/游戏),我搜索了几个问题,这里有一个类似的线程:从 Wordpress URL 中删除 index.php,但它没有回答我的问题
HYG 来自我的服务器的一些细节:
1)mod_rewrite
已启用
2)我有一个虚拟主机配置:
# domain name: test.com
# public: /var/www/test.com
# Admin email, Server Name (domain name) and any aliases
ServerAdmin test@gmail.com
ServerName test.com
ServerAlias www.test.com
# Index file and Document Root (where the public files are located)
# DirectoryIndex index.php
DocumentRoot /var/www/test.com
# Custom log file locations
LogLevel warn
ErrorLog /var/log/apache2/error-test.com.log
CustomLog /var/log/apache2/access-test.com.log combined
3)我有 .htaccess 如下:
Options FollowSymLinks
AllowOverride All
# BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
4) WordPress 目录权限为rwsr_xr_x
,其文件为rwx_r__r__ (owner www-data:www-data)
5)永久链接配置是/%year%/%monthnum%/%day%/%postname%/
我不熟悉 .htaccess 格式,所以可能需要对其进行一些调整,请指教?
解决方案
正常的 wordpress.htaccess
如下
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L] //you aren't escaping in your example
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
推荐阅读
- javascript - 如何连接通过 Node.js 中的 Mongoose 通过两个回调调用创建的字符串?
- string - 使用替换列表及其位置替换文件中的字符串
- r - R中的hurstexp()与hurstIndex()有什么区别
- java - 调用重载的构造函数
- azure-data-factory - 使用 Azure 数据工厂将具有可变列的 CSV 导入 Sql 数据库
- python-3.x - How to use return values from two functions to make an if statement and break process
- html - 是否有可以加载远程内容的 HTML 标记和 CSS 样式的封闭列表?
- c# - Linq Select 和 ToList 之间的性能差异
- java - 如何编写一个构造函数来调用一个构建自己的构建器?
- google-sheets - Google Spreadsheet fetch data from 2D array