2015-08-03 83 views
1

我有一个lighttpd的服务器的网络angularJS,但是当我刷新HTML5模式不起作用(错误404),或者做一个直接的联系。我有我的本地服务器运行Apache,在.htaccess中的重写表达式没有问题。 这是Apache代码:的lighttpd和AngularJS HTML5模式

<IfModule mod_rewrite.c> 
    Options +FollowSymlinks 
    #Options +SymLinksIfOwnerMatch 
    RewriteEngine On 
    RewriteRule !\.\w+$ index.html [L] 
</IfModule> 

,这是

server.modules = (
     "mod_access", 
     "mod_alias", 
     "mod_compress", 
     "mod_redirect", 
     "mod_rewrite", 
) 

server.document-root  = "/var/www/html" 
server.upload-dirs   = ("/var/cache/lighttpd/uploads") 
server.errorlog    = "/var/log/lighttpd/error.log" 
server.pid-file    = "/var/run/lighttpd.pid" 
server.username    = "www-data" 
server.groupname   = "www-data" 
server.port     = 80 


index-file.names   = ("index.php", "index.html", "index.lighttpd.html$ 
url.access-deny    = ("~", ".inc") 
static-file.exclude-extensions = (".php", ".pl", ".fcgi") 

compress.cache-dir   = "/var/cache/lighttpd/compress/" 
compress.filetype   = ("application/javascript", "text/css", "text/htm$ 

# default listening port for IPv6 falls back to the IPv4 port 
include_shell "/usr/share/lighttpd/use-ipv6.pl " + server.port 
include_shell "/usr/share/lighttpd/create-mime.assign.pl" 
include_shell "/usr/share/lighttpd/include-conf-enabled.pl" 

$HTTP["host"] == "myweb.io" { 
    server.document-root = "/var/www/html/" 
    url.rewrite-once = ("!\.\w+$" => "/index.html") 
} 

我已经找遍了所有的互联网,我还没有发现这事的lighttpd.conf的内容。我不知道如果我没有写好正则表达式,或者我把它放在错误的地方。

回答

0

只需设置以下的伎俩对我来说:(无需mod_rewrite的)

server.error-handler-404 = "/index.html" 

但是,要警惕在明显的bug旧版本如docs中所述。