多语言展示
当前在线:806今日阅读:195今日分享:14

lighttpd添加虚拟主机绑定域名并添加伪静态规则

上一篇教程我们讲到了关于debian安装lighttpd的教程,这次我们来讲一下关于lighttpd添加虚拟主机并绑定域名和添加伪静态的教程。
工具/原料

安装有lighttpd的主机

方法/步骤
1

1.新建单个虚拟主机:打开Lighttpd的配置文件/etc/lighttpd/lighttpd.conf,在最后添加如下段:$HTTP['host'] == 'www.a.com' {server.document-root = '网站路径'}如果需要多个虚拟主机,则将上面的段复制设置成多个不同域名即可。

3

3.伪静态功能:关于开启lighttpd的rewrite功能,只要将lighttpd.conf里的mod_rewrite前面的#去掉就可以了。下面这个是wordpress的伪静态规则。url.rewrite = ('^/(wp-.+).*/?' => '$0','^/(sitemap.xml)' => '$0','^/(xmlrpc.php)' => '$0','^/(.+)/?$' => '/index.php/$1')如果上面那个不起作用那么可以用下面这个看看。url.rewrite-final = (# Exclude some directories from rewriting'^/(wp-admin|wp-includes|wp-content|gallery2)/(.*)' => '$0',# Exclude .php files at root from rewriting'^/(.*.php)' => '$0',# Handle permalinks and feeds'^/(.*)$' => '/index.php/$1')

4

4.接着我们重启lighttpdservice lighttpd force-reload

注意事项

注意伪静态规则必须添加在域名规则的{ }之内,如果添加到了外面就不能使用了。

推荐信息