2017-02-27 97 views
0

我使用MAMP创建了一个虚拟主机。当我转到example.dev时,它运行良好。我只是在example.dev上安装了一个wordpress,没有任何问题。当我显示页面或帖子时,会在页面名称前添加一个/index.php。例如:example.dev/index.php/pagename。 我无法访问example.dev/pagename,我有一个404错误。 在固定链接的选项中,它会自动生成/index.php/%year%/%monthnum%/%day%/%postname%/。 我选择了http://example.dev/example-article/,但它仍然不起作用。index.php在wordpress中使用虚拟主机在url中添加

我有一个htaccess的在根

RewriteEngine On 

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

# END WordPress 

如果有人有一个想法......

谢谢!!

回答

0

到这个URL /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> 

END WordPress