【问题标题】:Open website pages and wordpress blog with the correct .htaccess settings使用正确的 .htaccess 设置打开网站页面和 wordpress 博客
【发布时间】:2016-08-13 09:01:25
【问题描述】:

我有一个结构如下的网站

public_html
   files and folders like index.php and terms.php - this is what loads mywebsite.com
   blog folder
     wp-admin
     wp-content
     wp-includes
     index.php

当我现在打开 mywebsite.com 时,它会加载。当我打开 mywebsite.com/terms 时,它会加载。当我打开 mywebsite.com/blog 时,它会加载。但 mywebsite.com/blog/my-first-post 无法加载。

根据 wordpress 我在 .htaccess 中设置:

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

现在 mywebsite.com/blog/my-first-post 会加载,但 mywebsite.com/ 之后的其他任何内容都不会加载。 mywebsite.com/terms 和 mywebsite.com/dashboard/myaccount 等都不是。由于某种原因,这些页面现在似乎在博客中,显然这就是它们显示 404 错误的原因。

【问题讨论】:

    标签: wordpress .htaccess


    【解决方案1】:

    您应该在public_html/blog 中添加这个.htaccess 文件:

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

    如果问题仍然存在,请告诉我。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-12-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-05-07
      相关资源
      最近更新 更多