首页 > 解决方案 > 所有链接中的奇怪 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 格式,所以可能需要对其进行一些调整,请指教?

标签: phpwordpress.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

推荐阅读