index.php在wordpress上添加了虚拟主机的url

时间:2017-02-27 17:14:38

标签: wordpress mamp virtualhost

我用MAMP创建了一个虚拟主机。当我去example.dev时它很好用。我刚刚在example.dev上安装了一个wordpress而没有任何问题。当我显示页面或帖子时,在页面名称之前添加了一个/index.php。例如:example.dev/index.php/pagename。 我无法访问example.dev/pagename,我有404错误。 在永久链接的选项中,它会自动生成package.json。 我选择了/index.php/%year%/%monthnum%/%day%/%postname%/,但它仍无效。

我在根

有一个htaccess
http://example.dev/example-article/

如果有人有想法......

谢谢!

1 个答案:

答案 0 :(得分:0)

此网址/index.php/%year%/%monthnum%/%day%/%postname%/将在Apache服务器上运行,将此规则添加到.htaccess文件

RewriteRule ^index.php/(.*)/?$ /$1/ [L] 

在WordPress规则之上:

RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

鉴于您的.htaccess具有基本的WordPress规则,它将如下所示:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php/(.*)/?$ /$1/ [L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

结束WordPress

相关问题