【问题标题】:Permalinks with Lighttpd and PHP-FPMLighttpd 和 PHP-FPM 的永久链接
【发布时间】:2012-01-30 13:48:42
【问题描述】:

我在我的服务器安装上使用 Lighttpd,并且永久链接与 PHP FastCGI 配合得很好。但最近我用 PHP-FPM 更改了 FastCGI,我的自定义永久链接不再起作用。

每次我点击帖子/页面时,wordpress 都会将我带到主页/首页。我的自定义永久链接是这样的 /%postname%-%post_id%.html 但是,如果我使用自定义永久链接,例如 /index.php/%postname%/ 或 /index.php/archives/%post_id% (​​包括 index.php),它就可以工作!但这不是我想要的..

我尝试在 lighttpd.conf 上使用 server.error-handler-404 = "/index.php" 但仍然没有成功。

任何帮助将不胜感激。 谢谢!

【问题讨论】:

    标签: wordpress lighttpd permalinks php


    【解决方案1】:

    尝试使用http://redmine.lighttpd.net/wiki/1/Docs:ModRewrite
    url.rewrite-once = ( "^/(.+)$" => "/index.php/$1" )
    不知道您是否需要一个特殊的结构,或者 wordpress 是否能够确定要查看哪些内容。
    关于您的错误处理程序:在 CGI 应用程序返回 404 之前它不会触发。根据您的描述,wordpress 在向您发送 404 错误之前更喜欢重定向。这就是它不起作用的原因:P

    【讨论】:

      【解决方案2】:

      是的,你是对的,我必须使用 mod rewrite。我的重写规则是这样的:

      $HTTP["host"] =~ "(^|\.)domain\.com$" {
         url.rewrite-once = (
            # Exclude additional specific directories from rewrites
            "^/(files)/?(.*)" => "$0",
            "^/(mysql)/?(.*)" => "$0",
      
            "^/(wp-.+).*/?" => "$0",
            "^/(favicon.ico)" => "$0",
            "^/(sitemap.xml)" => "$0",
            "^/(xmlrpc.php)" => "$0",
            "^/keyword/([A-Za-z_0-9-])/?$" => "index.php?keyword=$1",
            "^/(.+)/?$" => "index.php/$1"
         )  
      }
      

      现在它可以完美运行了。谢谢!

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-11-04
        • 1970-01-01
        • 2017-07-30
        • 2017-03-19
        • 1970-01-01
        相关资源
        最近更新 更多