注册
DLE中文网 » 教程VS分享 » Datalife Engine 伪静态规则

Datalife Engine 伪静态规则

10 五月 2022, 06:19
教程VS分享
107 073  
2
Datalife Engine 伪静态规则
server {
    listen       IP_ADDR:80;
    server_name HOST;

    root /path/to/root;

    rewrite ^/page/(.*)$ /index.php?cstart=$1 last;

    location / {
        rewrite "^/([0-9]{4})/([0-9]{2})/([0-9]{2})(/?)+$" /index.php?year=$1&month=$2&day=$3 last;
        rewrite "^/([0-9]{4})/([0-9]{2})/([0-9]{2})/page/([0-9]+)(/?)+$" /index.php?year=$1&month=$2&day=$3&cstart=$4 last;
        rewrite "^/([0-9]{4})/([0-9]{2})(/?)+$" /index.php?year=$1&month=$2 last;
        rewrite "^/([0-9]{4})/([0-9]{2})/page/([0-9]+)(/?)+$" /index.php?year=$1&month=$2&cstart=$3 last;
        rewrite "^/([0-9]{4})(/?)+$" /index.php?year=$1 last;
        rewrite "^/([0-9]{4})/page/([0-9]+)(/?)+$" /index.php?year=$1&cstart=$2 last;
        rewrite "^/([^.]+)/page/([0-9]+)(/?)+$" /index.php?do=cat&category=$1&cstart=$2 last; 
        rewrite "^/([^.]+)(/?)+$" /index.php?do=cat&category=$1 last;
        index  index.php index.html index.htm;
    }

    location /tags/ {
        rewrite ^/tags/([^/]*)(/?)+$ /index.php?do=tags&tag=$1 last;
        rewrite ^/tags/([^/]*)/page/([0-9]+)(/?)+$ /index.php?do=tags&tag=$1&cstart=$2 last;
    }

    location /user/ {
        rewrite ^/user/([^/]*)/rss.xml$ /engine/rss.php?subaction=allnews&user=$1 last;
        rewrite ^/user/([^/]*)(/?)+$ /index.php?subaction=userinfo&user=$1 last;
        rewrite ^/user/([^/]*)/page/([0-9]+)(/?)+$ /index.php?subaction=userinfo&user=$1&cstart=$2 last;
        rewrite ^/user/([^/]*)/news(/?)+$ /index.php?subaction=allnews&user=$1 last;
        rewrite ^/user/([^/]*)/news/page/([0-9]+)(/?)+$ /index.php?subaction=allnews&user=$1&cstart=$2 last;
        rewrite ^/user/([^/]*)/news/rss.xml(/?)+$ /engine/rss.php?subaction=allnews&user=$1 last;
    }

    location /lastnews/ {
        rewrite ^/lastnews/(/?)+$ index.php?do=lastnews last;
        rewrite ^/lastnews/page/([0-9]+)(/?)+$ /index.php?do=lastnews&cstart=$1 last;
    }

    location /catalog/ {
        rewrite ^/catalog/([^/]*)/rss.xml$ /engine/rss.php?catalog=$1 last;
        rewrite ^/catalog/([^/]*)(/?)+$ /index.php?catalog=$1 last;
        rewrite ^/catalog/([^/]*)/page/([0-9]+)(/?)+$ /index.php?catalog=$1&cstart=$2 last;
    }

    location /newposts {
        rewrite ^/newposts(/?)+$ /index.php?subaction=newposts last;
        rewrite ^/newposts/page/([0-9]+)(/?)+$ /index.php?subaction=newposts&cstart=$1 last;
    }

    location /favorites {
        rewrite ^/favorites(/?)+$ /index.php?do=favorites last;
        rewrite ^/favorites/page/([0-9]+)(/?)+$ /index.php?do=favorites&cstart=$1 last;
    }

    location ~ \.(html|xml) {
        rewrite "^/([0-9]{4})/([0-9]{2})/([0-9]{2})/page,([0-9]+),([0-9]+),(.*).html(/?)+$" /index.php?subaction=showfull&year=$1&month=$2&day=$3&news_page=$4&cstart=$5&news_name=$6 last;
        rewrite "^/([0-9]{4})/([0-9]{2})/([0-9]{2})/page,([0-9]+),(.*).html(/?)+$" /index.php?subaction=showfull&year=$1&month=$2&day=$3&news_page=$4&news_name=$5 last;
        rewrite "^/([0-9]{4})/([0-9]{2})/([0-9]{2})/print:page,([0-9]+),(.*).html(/?)+$" /engine/print.php?subaction=showfull&year=$1&month=$2&day=$3&news_page=$4&news_name=$5 last;
        rewrite "^/([0-9]{4})/([0-9]{2})/([0-9]{2})/(.*).html(/?)+$" /index.php?subaction=showfull&year=$1&month=$2&day=$3&news_name=$4 last;
        rewrite "^/([^.]+)/page,([0-9]+),([0-9]+),([0-9]+)-(.*).html(/?)+$" /index.php?newsid=$4&news_page=$2&cstart=$3 last;
        rewrite "^/([^.]+)/page,([0-9]+),([0-9]+)-(.*).html(/?)+$" /index.php?newsid=$3&news_page=$2 last;
        rewrite "^/([^.]+)/print:page,([0-9]+),([0-9]+)-(.*).html(/?)+$" /engine/print.php?news_page=$2&newsid=$3 last;
        rewrite "^/([^.]+)/([0-9]+)-(.*).html(/?)+$" /index.php?newsid=$2 last;
        rewrite "^/page,([0-9]+),([0-9]+),([0-9]+)-(.*).html(/?)+$" /index.php?newsid=$3&news_page=$1&cstart=$2 last;
        rewrite "^/page,([0-9]+),([0-9]+)-(.*).html(/?)+$" /index.php?newsid=$2&news_page=$1 last;
        rewrite "^/print:page,([0-9]+),([0-9]+)-(.*).html(/?)+$" /engine/print.php?news_page=$1&newsid=$2 last;
        rewrite "^/([0-9]+)-(.*).html(/?)+$" /index.php?newsid=$1 last;
        rewrite "^/static/(.*).html(/?)+$" /index.php?do=static&page=$1 last;
        rewrite ^/rules.html$ /index.php?do=rules last;
        rewrite ^/statistics.html$ /index.php?do=stats last;
        rewrite ^/addnews.html$ /index.php?do=addnews last;
        rewrite ^/([^.]+)/rss.xml$ /engine/rss.php?do=cat&category=$1 last;
        rewrite ^/page,([0-9]+),([^/]+).html$ /index.php?do=static&page=$2&news_page=$1 last;
        rewrite ^/print:([^/]+).html$ /engine/print.php?do=static&page=$1 last;
        rewrite ^/rss.xml$ /engine/rss.php last;
        rewrite ^/sitemap.xml$ /uploads/sitemap.xml last;
        rewrite ^/([^/]+).html$ /index.php?do=static&page=$1 last;
    }

## Что-бы закрыть папки, которые были закрыты через .htaccess, используем подобные конструкции
    location ~* (uploads|uploads/fotos|templates|language)/.+\.php {
        deny all;
    }

    location ~* /templates/.+\.tpl {
        deny all;
    }

    location ~* (engine/cache) {
        deny all;
    }

    location ~ /\.ht {
        deny  all;
    }

    location ~* \.(jpg|jpeg|gif|png|ico|swf|css|js)$ {
        expires             30d;
        add_header          Cache-Control public;
    }

##  Тут установлен дополнительный пароль на админку
    location =/admin.php {
        auth_basic            "closed section";
        auth_basic_user_file  htpasswd;
        fastcgi_pass   unix:/tmp/fastcgi.sock;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }

    location ~ \.php$ {
        fastcgi_pass   unix:/tmp/fastcgi.sock;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }
}
评论列表
注释的最小长度为10个汉子。评论正在编辑中
如果验证码看不清,请点击图片刷新
rocky
rocky
10 五月 2022 21:54

其实用不着这么多,根据自己实际情况,跳着rewrite部分即可。

Lupe
Lupe
8 十月 2026 03:33
https://www.bing.com/maps?ty=18&q=SEO+co+-+%D7%97%D7%91%D7%A8%D7%AA+%D7%A7%
D7%99%D7%93%D7%95%D7%9D+%D7%90%D7%AA%D7%A8%D7%99%D7%9D%2C+%D7%97%D7%A8%D7%95%D7
%AA+46%2C+Tel+Aviv%2C+Tel-Aviv+District%2C+Israel&ss=ypid.YN8083x1715760596
8432132913&mb=32.096782%7E34.804065%7E32.085529%7E34.82621&description=
Tel+Aviv&usebfpr=true&cardbg=%2388979C&tt=SEO+co&tsts0=%2526ty%
253D18%2526q%253DSEO%252520co%252520-%252520%2525D7%252597%2525D7%252591%2525D7
%2525A8%2525D7%2525AA%252520%2525D7%2525A7%2525D7%252599%2525D7%252593%2525D7%2
52595%2525D7%25259D%252520%2525D7%252590%2525D7%2525AA%2525D7%2525A8%2525D7%252
599%2525D7%25259D%25252C%252520%2525D7%252597%2525D7%2525A8%2525D7%252595%2525D
7%2525AA%25252046%25252C%252520Tel%252520Aviv%25252C%252520Tel-Aviv%252520Distr
ict%25252C%252520Israel%2526ss%253Dypid.YN8083x17157605968432132913%2526mb%253D
32.096782%7E34.804065%7E32.085529%7E34.82621%2526description%253DTel%252520Aviv
%2526usebfpr%253Dtrue%2526cardbg%253D%25252388979C&tstt0=SEO+co&cp=32.0
91155%7E34.815137&lvl=16.0&ftst=0&ftics=False&v=2&sV=2&
form=S00027 SEO co - חברת קידום אתרים Thanks designed for sharing such a nice idea, post is fastidious, thats why i have read it entirely

相关新闻:

讨论区 / COMMENTS ×