所有链接里面都有奇怪的WordPress index.php

内容来源于 Stack Overflow,并遵循CC BY-SA 3.0许可协议进行翻译与使用

  • 回答 (1)
  • 关注 (0)
  • 查看 (254)

我之前安装了几个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

扫码关注云+社区

领取腾讯云代金券