Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/260.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 刚刚启动apache.htaccess重写到lighttpd转换_Php_Apache_.htaccess_Mod Rewrite_Lighttpd - Fatal编程技术网

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

Php 刚刚启动apache.htaccess重写到lighttpd转换,php,apache,.htaccess,mod-rewrite,lighttpd,Php,Apache,.htaccess,Mod Rewrite,Lighttpd,下面是apache中的.htaccess文件。我在我的子目录中发现了一个404NotFound错误,我确信这与我的重写有关 Options -Indexes Options +FollowSymLinks <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{HTTP_HOST} ^example.com [NC] RewriteRule ^(.*)$ http://www.example.com/$1

下面是apache中的.htaccess文件。我在我的子目录中发现了一个404NotFound错误,我确信这与我的重写有关

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>
我知道“$1.php”不是正确的答案。这是可行的,但我不认为它是有功能的。这里的唯一目的是帮助我完成我的工作。

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

为了

因为-f和-d参见
url。如果不是文件,请重写

对于QSA,使用lighttpd条件块匹配查询字符串,然后用%1替换,例如

$HTTP["querystring"] =~ "(.*)" {
  url.rewrite-if-not-file = ( "..." => "...&%1" )
} else {
  url.rewrite-if-not-file = ( "..." => "..." )
}
$HTTP["host"] == "example.com" {
    url.redirect = ( "^(.*)$" => "http://www.example.com$1" )
}
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* file.php [L,QSA]
$HTTP["querystring"] =~ "(.*)" {
  url.rewrite-if-not-file = ( "..." => "...&%1" )
} else {
  url.rewrite-if-not-file = ( "..." => "..." )
}