【问题标题】:index.php added in url with virtualhost on wordpressindex.php 在 url 中添加了 wordpress 上的虚拟主机
【发布时间】:2017-07-18 10:10:59
【问题描述】:

我用 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/,但还是不行。

我在根目录下有一个 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

如果有人有想法...

谢谢!!

【问题讨论】:

    标签: wordpress mamp virtualhost


    【解决方案1】:

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

    结束 WordPress

    【讨论】:

      猜你喜欢
      • 2016-05-12
      • 2017-02-06
      • 2013-08-14
      • 2012-09-22
      • 2012-07-08
      • 2017-02-27
      • 2020-06-24
      • 1970-01-01
      • 2011-03-25
      相关资源
      最近更新 更多