douping6871 2017-03-11 15:36
浏览 79

刚刚启动apache .htaccess重写到lighttpd转换

Below is my .htaccess file from apache. I'm getting a 404 not found error on my subdirectories, and I am certain it has to do with my rewrite.

Options -Indexes
Options +FollowSymLinks

<IfModule mod_rewrite.c>
  RewriteEngine On

    RewriteCond %{HTTP_HOST} ^example.com [NC]
    RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule .* file.php [L,QSA]

</IfModule>

Here is my lighttpd.conf rewrite

$HTTP["host"] =~ "www.example.com" {
url.rewrite           = ( "^(.*)$" => "$1.php" )
}

server.follow-symlink = "enable"

I know the "$1.php" isn't the right answer. It sort-of works, but I wouldn't consider it functional. It's sole purpose here is to help put together what I'm trying to do.

  • 写回答

1条回答 默认 最新

  • dton37910 2017-03-15 05:07
    关注

    For

    RewriteCond %{HTTP_HOST} ^example.com [NC]
    RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
    

    see https://redmine.lighttpd.net/projects/lighttpd/wiki/Docs_ModRedirect

    $HTTP["host"] == "example.com" {
        url.redirect = ( "^(.*)$" => "http://www.example.com$1" )
    }
    

    For

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule .* file.php [L,QSA]
    

    https://redmine.lighttpd.net/boards/2/topics/6459

    For !-f and !-d See url.rewrite-if-not-file in https://redmine.lighttpd.net/projects/lighttpd/wiki/Docs_ModRewrite

    For QSA, match the query string using a lighttpd condition block and then substitute with %1, e.g.

    $HTTP["querystring"] =~ "(.*)" {
      url.rewrite-if-not-file = ( "..." => "...&%1" )
    } else {
      url.rewrite-if-not-file = ( "..." => "..." )
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog