【问题标题】:Use .html pages with WordPress在 WordPress 中使用 .html 页面
【发布时间】:2017-03-16 01:06:08
【问题描述】:

我的 wordpress 与我的静态 .html 页面位于同一目录中。我怎样才能做到这一点,当我想访问 example.com/test-page 时,如果有 html 版本,它将自动转到 html 版本。

如果没有 .html 版本,则会转到 wordpress 版本。我怎样才能做到这一点?谢谢

我试过这个:

DirectoryIndex index.html index.php

但我认为这仅适用于索引页面。我怎样才能在全球范围内做到这一点?也许通过 .htaccess?

【问题讨论】:

    标签: php html wordpress apache .htaccess


    【解决方案1】:

    您可以使用以下规则:

    RewriteEngine on
    
    RewriteCond %{REQUEST_FILENAME}.html -f
     RewriteRule ^(.*?)/?$ /$1.html [L]
    

    这将在内部重定向 html 请求,例如:/page//page.html

    【讨论】:

    • 它现在给了我一个 404 页面。我应该在默认的 wordpress .htaccess 代码之前添加它吗?
    • 好的,我在默认的 wordpress .htaccess 代码之前添加了它,它起作用了!谢谢! :)
    猜你喜欢
    • 2015-07-19
    • 1970-01-01
    • 2019-02-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-14
    相关资源
    最近更新 更多