时间: 2011-04-13 / 分类: WEB后端编程 - 开发与实践 / 浏览次数: / 2 个评论 发表评论
Nginx服务器下的.htaccess应用在Destoon上的规则
WEB前端开发中的一些编程风格和书...
项目前端开发的架构
黄金分割与摄影构图
CSS Hack浏览器兼容IE6+IE7+IE8+IE9+FF

Nginx下的.htaccess和Apache下的.htaccess的规则是有所不同的,大部分适用于windows和linux下的apache的.htaccess并不适用于nginx的.htaccess规则,所以需要进行转换一下,有一个可以直接在线转换htaccess的工具,点击 http://www.anilcetin.com/convert-apache-htaccess-to-nginx/ 链接进入转换;

转换好了之后要在nginx.conf的配置文件里面server段修改一下,大致如下所示:

server {
        listen       80;
        server_name  localhost
www.amiku.cn amiku.cn;
        #access_log  logs/host.access.log  main;
        root   /www;
        index  index.html index.htm index.;
        include /www/.;
       ………………

增加一段include /www/.htaccess,具体路径和具体规则文件所放的位置有关。

修改好了重启一下nginx即可: /usr/local//sbin/ -s reload

在Destoon中的.htaccess规则,修改了一下,如下所示:

# Below .htaccess rules is for revised by <i@amiku.cn> 2011-04-13 10:22
##B2B 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 ^(.*)/com/([a-z0-9]+)/([a-z]+)/(.*)\.html$ $1/company/$3/index.php?homepage=$2&rewrite=$4
#RewriteRule ^(.*)/com/([a-z0-9]+)/([a-z]+)([/])?$ $1/company/$3/index.php?homepage=$2
#RewriteRule ^(.*)/com/([a-z0-9]+)([/])?$ $1/company/index.php?homepage=$2
#RewriteRule ^(.*)/([a-z]+)/(.*)\.shtml$ $1/$2/index.php?rewrite=$3

# Below .htaccess rules is for Nginx revised by <i@amiku.cn> 2011-04-13 10:22

rewrite ^(.*)\.(asp|aspx|asa|asax|dll|jsp|cgi|fcgi|pl)(.*)$ /404.php;
rewrite ^(.*)-htm-(.*)$ $1.php?$2;
rewrite ^(.*)/show-([0-9]+)([\-])?([0-9]+)?\.html$ $1/show.php?itemid=$2&page=$4;
rewrite ^(.*)/list-([0-9]+)([\-])?([0-9]+)?\.html$ $1/list.php?catid=$2&page=$4;
rewrite ^(.*)/show/([0-9]+)/([0-9]+)?([/])?$ $1/show.php?itemid=$2&page=$3;
rewrite ^(.*)/list/([0-9]+)/([0-9]+)?([/])?$ $1/list.php?catid=$2&page=$3;
rewrite ^(.*)/([a-z]+)/(.*)\.shtml$ $1/$2/index.php?rewrite=$3;

rewrite ^(.*)/com/([a-z0-9]+)/([a-z]+)/(.*)\.html$ $1/company/$3/index.php?homepage=$2&rewrite=$4;
rewrite ^(.*)/com/([a-z0-9]+)/([a-z]+)([/])?$ $1/company/$3/index.php?homepage=$2;
rewrite ^(.*)/com/([a-z0-9]+)([/])?$ $1/company/index.php?homepage=$2;
rewrite ^([a-z0-9]+)\.co([/])?$ company/index.php?homepage=$1;
rewrite ^([a-z0-9]+)\.co/(.*)$ company/index.php?homepage=$1&rewrite=$2;
rewrite ^(htm)/(.*)$ index.php?&rewrite=$2;

或者 点击下载 此txt文件,然后改名成.htaccess,上传上去即可。

  1. 你好。为什么我设置后还是无效呢。我在/conf 下面修改了Destoon.conf 在根目录下面也设置了。却还是失败。

    回复

  站点地图 | 关于我 | 返回顶部
Copyright © 2001-2013 { amiku.cn | zhangshunjin.com }. Powered by 

阿米酷

张顺金


浙ICP备11002820号-1