Rewrite – Apache转Lighttpd的伪静态rewrite方法
来源:互联网 发布:mac强制卸载程序 编辑:程序博客网 时间:2024/05/21 17:33
市面上大部分伪静态都是Apache下的.htaccess,因为Apache的伪静态可以独立为文件,所以Apache比较适合IDC,所以也导致Lighttpd的伪静态比较少开源程序会提供出来。
其实Lighttpd的rewrite写法和Apache的大同小异,无非是正则嘛,本人认为最大的区别在于Lighttpd的rewrite规则是写在了lighttpd.conf中。
首先在lighttpd的配置文件中要加入rewrite模块:
1
server.modules = (
"mod_rewrite"
)
lighttpd伪静态放置位置为url.rewrite-once=() 中,格式为:
1
2
3
4
url.rewrite-once = (
"<regex1>"
=>
"<relative-uri1>"
,
"<regex2>"
=>
"<relative-uri2>"
)
这个url.rewrite-once放置的位置就自己看着办了。要哪部分生效就放哪里。
再说一下Apache的.htaccess如何转换为lighttpd的
以下是Destoon系统的apache伪静态规则:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# Destoon B2B Rewrite Rules
ErrorDocument 404
/404
.php
RewriteEngine On
RewriteBase /
RewriteRule ^(.*)\.(asp|aspx|asa|asax|dll|jsp|cgi|fcgi|pl)(.*)$
/404
.php
RewriteRule ^(.*)-htm-(.*)$ $1.php?$2
RewriteRule ^(.*)
/show-
([0-9]+)([\-])?([0-9]+)?\.html$ $1
/show
.php?itemid=$2&page=$4
RewriteRule ^(.*)
/list-
([0-9]+)([\-])?([0-9]+)?\.html$ $1
/list
.php?catid=$2&page=$4
RewriteRule ^(.*)
/show/
([0-9]+)/([0-9]+)?([/])?$ $1
/show
.php?itemid=$2&page=$3
RewriteRule ^(.*)
/list/
([0-9]+)/([0-9]+)?([/])?$ $1
/list
.php?catid=$2&page=$3
RewriteRule ^(.*)/([a-z]+)/(.*)\.shtml$ $1/$2
/index
.php?rewrite=$3
RewriteRule ^(com)/([a-z0-9_]+)/([a-z]+)/(.*)\.html$ index.php?homepage=$2&rewrite=$4
RewriteRule ^(com)/([a-z0-9_]+)/([a-z]+)([/])?$ index.php?homepage=$2
RewriteRule ^(com)/([a-z0-9_]+)([/])?$ index.php?homepage=$2
转成Lighttpd后:
1
2
3
4
5
6
7
8
9
10
11
12
url.rewrite-once=(
"^(.*)\.(asp|aspx|asa|asax|dll|jsp|cgi|fcgi|pl)(.*)$"
=>
"/404.php"
,
"^(.*)-htm-(.*)$"
=>
"$1.php?$2"
,
"^(.*)/show-([0-9]+)([\-])?([0-9]+)?\.html$"
=>
"$1/show.php?itemid=$2&page=$4"
,
"^(.*)/list-([0-9]+)([\-])?([0-9]+)?\.html$"
=>
"$1/list.php?catid=$2&page=$4"
,
"^(.*)/show/([0-9]+)/([0-9]+)?([/])?$"
=>
"$1/show.php?itemid=$2&page=$3"
,
"^(.*)/list/([0-9]+)/([0-9]+)?([/])?$"
=>
"$1/list.php?catid=$2&page=$3"
,
"^(.*)/([a-z]+)/(.*)\.shtml$"
=>
"$1/$2/index.php?rewrite=$3"
,
"^(com)/([a-z0-9_]+)/([a-z]+)/(.*)\.html$"
=>
"index.php?homepage=$2&rewrite=$4"
,
"^(com)/([a-z0-9_]+)/([a-z]+)([/])?$"
=>
"index.php?homepage=$2"
,
"^(com)/([a-z0-9_]+)([/])?$"
=>
"index.php?homepage=$2"
)
简单来说就几步(替换含双引号和空格,【】中为内容):
1、把无用的RewriteEngine On和RewriteBase /去掉,只剩下RewriteRule开头的内容;
2、把【RewriteRule 】(注意空格)替换为双引号【”】;
3、把apache规则里每条规则中间的空格替换为【” => “】;
4、在每条规则后加上【”,】,注意最后一条不要只加【”】原因自己理解;
5、基本完成,在整段内容前加上【url.rewrite-once=(】,整段内容后加上【)】;
6、完成。
阅读全文
0 0
- Rewrite – Apache转Lighttpd的伪静态rewrite方法
- Apache下伪静态html(URL Rewrite)的设置方法
- Apache和Nginx设置伪静态(URL Rewrite)的方法
- apache rewrite的伪静态实现
- Lighttpd下WORDPRESS的URL Rewrite伪静态规则
- Apache Rewrite 伪静态配置
- URL Rewrite伪静态规则转换工具,支持Apache、Lighttpd和Nginx
- 利用Apache的rewrite实现URL的伪静态化
- 用Apache的rewrite生成伪静态页面
- Apache URL Rewrite配置(php 伪静态)
- Apache Url Rewrite 配置(php伪静态)
- Apache Rewrite 实现网页伪静态
- php 伪静态(url rewrite)apache配置!
- php 伪静态(url rewrite)apache配置!
- php 伪静态(url rewrite)apache配置!
- apache 开启伪静态 Rewrite及检测
- Ubuntu Apache 开启加载Rewrite 伪静态
- URL rewrite,Apache 伪静态规则配置
- Python2.x与3.x版本区别
- WebService 的创建,部署和使用
- 【选择题】Java基础测试二(15道)
- Xshell 连接到虚拟机的ubuntu
- HDU1163
- Rewrite – Apache转Lighttpd的伪静态rewrite方法
- Django blog
- 在同一台服务器上配置多个Tomcat
- Xcode9 无线调试教程
- 数组中只出现一次的数字
- jquery easyUI 日期格式化,DateBox只显示年
- Facebook在代码里下毒,百度身受重伤。。。
- MySQL聚簇索引和非聚簇索引的原理及使用
- AndroidStudio更新gradle失败问题