【问题标题】:Strange WordPress index.php inside all the links所有链接中的奇怪 WordPress index.php
【发布时间】:2018-07-04 03:33:36
【问题描述】:

我之前安装了几台 WordPress 服务器,但这是我第一次遇到这个问题,所有链接的 URL 中都必须包含“index.php”(即 test.com/games 而不是 test.com/index .php/games),我搜索了几个问题,这里有一个类似的线程:Remove index.php from Wordpress URLs 但它没有回答我的问题

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 格式不熟悉,所以可能需要对其进行一些调整,请指教?

【问题讨论】:

  • DirectoryIndex index.php为什么被注释掉了?
  • 它没有被注释掉,但我在尝试解决问题时注释掉了
  • 我现在退回了,但同样的问题仍然存在
  • 我注意到更改永久链接配置不会影响 .htaccess,因此我将其权限临时更改为 777,但这并没有解决问题

标签: php wordpress .htaccess


【解决方案1】:

正常的wordpress.htaccess是一个followers

# 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

【讨论】:

  • 谢谢,但按上述方式更改并不能解决问题,实际上这是我开始寻找解决方案之前的格式,您认为我应该检查其他内容吗?
  • wp_options表中home_url的值是多少?
  • siteurl 和 home 值都是域名(即test.com
  • 这可能很愚蠢,但您是否在更改后刷新了永久链接?
  • 是的,每次我进行更改时,我都尝试更改永久链接并查看输出
猜你喜欢
  • 1970-01-01
  • 2023-03-28
  • 2017-07-27
  • 2016-11-06
  • 1970-01-01
  • 1970-01-01
  • 2014-04-10
  • 1970-01-01
  • 2019-08-28
相关资源
最近更新 更多