简体   繁体   English

在wordpress上使用virtualhost在URL中添加index.php

[英]index.php added in url with virtualhost on wordpress

I created a virtualhost with MAMP. 我用MAMP创建了一个虚拟主机。 It works well when I go to example.dev. 当我转到example.dev时,它运行良好。 I just installed a wordpress on example.dev without any problems. 我只是在example.dev上安装了一个wordpress,没有任何问题。 When I display a page or a post, there is a /index.php which is added before the page name. 当我显示页面或帖子时,在页面名称之前会添加一个/index.php。 For example : example.dev/ index.php /pagename. 例如:example.dev/ index.php / pagename。 I can not access example.dev/pagename, i have a 404 error. 我无法访问example.dev/pagename,但出现404错误。 In permalink's options, it generates automatically /index.php/%year%/%monthnum%/%day%/%postname%/ . 在永久链接的选项中,它会自动生成/index.php/%year%/%monthnum%/%day%/%postname%/ I selected http://example.dev/example-article/ but it is still not working. 我选择了http://example.dev/example-article/但仍然无法正常工作。

I have a htaccess at the root 我的根有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

If somebody has an idea... 如果有人有主意...

Thank you !! 谢谢 !!

To this url /index.php/%year%/%monthnum%/%day%/%postname%/ will work on Apache server add this rule to .htaccess file 到此url /index.php/%year%/%monthnum%/%day%/%postname%/可以在Apache服务器上运行将此规则添加到.htaccess文件中

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

Above the WordPress rules: 以上WordPress规则:

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

Given that your .htaccess have the basic WordPress rules it would look like this: 鉴于您的.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 结束WordPress

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM