简体   繁体   English

刚开始apache .htaccess重写为lighttpd转换

[英]just started apache .htaccess rewrite to lighttpd conversion

Below is my .htaccess file from apache. 以下是我来自apache的.htaccess文件。 I'm getting a 404 not found error on my subdirectories, and I am certain it has to do with my rewrite. 我的子目录上出现404 not found错误,并且我确定这与我的重写有关。

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 这是我的lighttpd.conf重写

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

server.follow-symlink = "enable"

I know the "$1.php" isn't the right answer. 我知道“ $ 1.php”不是正确的答案。 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. 这里的唯一目的是帮助整合我正在尝试做的事情。

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 参见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 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 对于!-f和!-d见url.rewrite-if-not-filehttps://redmine.lighttpd.net/projects/lighttpd/wiki/Docs_ModRewrite

For QSA, match the query string using a lighttpd condition block and then substitute with %1, eg 对于QSA,请使用lighttpd条件块匹配查询字符串,然后将其替换为%1,例如

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM