所有链接中都包含奇怪的WordPress index.php

时间:2018-07-03 19:16:07

标签: php wordpress .htaccess

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

从我的服务器上获取一些详细信息:

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格式不熟悉,因此可能需要对其进行一些调整,请告知?

1 个答案:

答案 0 :(得分:0)

普通的.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