3个月前 (03-02)  内容管理系统 |   1 条评论  36 
文章评分 0 次,平均分 0.0

本文给出 IPS Community Suite 4.2.6 可用的 Nginx 重写规则。

在 IPS Community Suite 后台,可以直接下载 Apache 的重写规则,但是没有对 Nginx 支持太好,所以,就需要根据自己的情况,写下适用于 Nginx 的重写规则了。

This post will give you a sample about how to config your IPS Community Suite SEO Urls on Nginx .

IPS Community Suite Nginx rewrite rules as following:

<span class="pln">server</span><span class="pun">{</span><span class="pln">

    listen </span><span class="lit">80</span><span class="pun">;</span> <span class="com">#listen end</span><span class="pln">
    server_name </span><span class="pun">你的域名;</span><span class="pln">
    index index</span><span class="pun">.</span><span class="pln">html index</span><span class="pun">.</span><span class="pln">htm index</span><span class="pun">.</span><span class="pln">php</span><span class="pun">;</span>

    <span class="com">#set $subdomain '';</span>
    <span class="com">#root  /home/wwwroot/html/$subdomain;</span>
    <span class="com">#或者直接写绝对路径</span><span class="pln">
    root  </span><span class="pun">/</span><span class="pln">home</span><span class="pun">/</span><span class="pln">wwwroot</span><span class="pun">/</span><span class="pln">html</span><span class="pun">/你的域名;</span>

    <span class="com"># 包含其它 Nginx 配置,一般是 fastcgi 相关的配置文件</span>
    <span class="com">#include</span> <span class="pun">/</span><span class="pln">home</span><span class="com">/**/</span><span class="pln">other</span><span class="pun">.</span><span class="pln">conf</span><span class="pun">;</span> <span class="com">#rewrite end</span>


    <span class="com"># Set up rewrite rules.</span><span class="pln">
    location </span><span class="pun">/</span> <span class="pun">{</span>
        <span class="com"># index  index.php;</span><span class="pln">
        try_files  $uri $uri</span><span class="pun">/</span> <span class="pun">/</span><span class="pln">index</span><span class="pun">.</span><span class="pln">php</span><span class="pun">;</span>
        <span class="com"># 下面的也行</span>
        <span class="com"># try_files $uri $uri/ /index.php?$args;</span>
    <span class="pun">}</span><span class="pln">

    location </span><span class="pun">~^(</span><span class="str">/page/</span><span class="pun">).*(.</span><span class="pln">php</span><span class="pun">)</span><span class="pln">$ </span><span class="pun">{</span><span class="pln">
        try_files  $uri $uri</span><span class="pun">/</span> <span class="pun">/</span><span class="pln">index</span><span class="pun">.</span><span class="pln">php</span><span class="pun">;</span>
    <span class="pun">}</span>

    <span class="com"># Stub Status module</span><span class="pln">
    location </span><span class="pun">/</span><span class="pln">server_status </span><span class="pun">{</span>
        <span class="com"># stub_status on;</span>
        <span class="com">#allow 127.0.0.1;</span>
        <span class="com">#deny all;</span>
    <span class="pun">}</span>

   <span class="com"># GZIP static content not processed by IPB.</span><span class="pln">
    gzip  on</span><span class="pun">;</span><span class="pln">
    gzip_static on</span><span class="pun">;</span><span class="pln">
    gzip_http_version </span><span class="lit">1.1</span><span class="pun">;</span><span class="pln">
    gzip_vary on</span><span class="pun">;</span><span class="pln">
    gzip_comp_level </span><span class="lit">6</span><span class="pun">;</span><span class="pln">
    gzip_proxied any</span><span class="pun">;</span><span class="pln">
    gzip_types text</span><span class="pun">/</span><span class="pln">plain text</span><span class="pun">/</span><span class="pln">css application</span><span class="pun">/</span><span class="pln">json application</span><span class="pun">/</span><span class="pln">x</span><span class="pun">-</span><span class="pln">javascript application</span><span class="pun">/</span><span class="pln">xml application</span><span class="pun">/</span><span class="pln">xml</span><span class="pun">+</span><span class="pln">rss text</span><span class="pun">/</span><span class="pln">javascript application</span><span class="pun">/</span><span class="pln">javascript text</span><span class="pun">/</span><span class="pln">x</span><span class="pun">-</span><span class="pln">js</span><span class="pun">;</span><span class="pln">
    gzip_buffers </span><span class="lit">16</span> <span class="lit">8k</span><span class="pun">;</span><span class="pln">
    gzip_disable </span><span class="str">"MSIE [1-6].(?!.*SV1)"</span><span class="pun">;</span>

    <span class="com"># IP.Board PHP/CGI Protection</span><span class="pln">
    location </span><span class="pun">~^(</span><span class="str">/uploads/</span><span class="pun">).*(.</span><span class="pln">php</span><span class="pun">)</span><span class="pln">$ </span><span class="pun">{</span><span class="pln">
        deny     all</span><span class="pun">;</span>
    <span class="pun">}</span><span class="pln">
    location </span><span class="pun">~^(</span><span class="str">/hooks/</span><span class="pun">).*(.</span><span class="pln">php</span><span class="pun">)</span><span class="pln">$ </span><span class="pun">{</span><span class="pln">
        deny     all</span><span class="pun">;</span>
    <span class="pun">}</span><span class="pln">
    location </span><span class="pun">~^(</span><span class="str">/cache/</span><span class="pun">).*(.</span><span class="pln">php</span><span class="pun">)</span><span class="pln">$ </span><span class="pun">{</span><span class="pln">
        deny     all</span><span class="pun">;</span>
    <span class="pun">}</span><span class="pln">
    location </span><span class="pun">~^(</span><span class="str">/screenshots/</span><span class="pun">).*(.</span><span class="pln">php</span><span class="pun">)</span><span class="pln">$ </span><span class="pun">{</span><span class="pln">
        deny     all</span><span class="pun">;</span>
    <span class="pun">}</span><span class="pln">
    location </span><span class="pun">~^(</span><span class="str">/downloads/</span><span class="pun">).*(.</span><span class="pln">php</span><span class="pun">)</span><span class="pln">$ </span><span class="pun">{</span><span class="pln">
        deny     all</span><span class="pun">;</span>
    <span class="pun">}</span><span class="pln">
    location </span><span class="pun">~^(</span><span class="str">/blog/</span><span class="pun">).*(.</span><span class="pln">php</span><span class="pun">)</span><span class="pln">$ </span><span class="pun">{</span><span class="pln">
        deny     all</span><span class="pun">;</span>
    <span class="pun">}</span><span class="pln">
    location </span><span class="pun">~^(</span><span class="str">/public/</span><span class="pln">style_</span><span class="pun">).*(.</span><span class="pln">php</span><span class="pun">)</span><span class="pln">$ </span><span class="pun">{</span><span class="pln">
        deny     all</span><span class="pun">;</span>
    <span class="pun">}</span>
     <span class="com"># Caching directives for static files.</span><span class="pln">
    location </span><span class="pun">~^(</span><span class="str">/uploads/</span><span class="pln">profile</span><span class="pun">/).*.(</span><span class="pln">jpg</span><span class="pun">|</span><span class="pln">jpeg</span><span class="pun">|</span><span class="pln">gif</span><span class="pun">|</span><span class="pln">png</span><span class="pun">)</span><span class="pln">$ </span><span class="pun">{</span><span class="pln">
        access_log off</span><span class="pun">;</span><span class="pln">
        expires    </span><span class="lit">1d</span><span class="pun">;</span>
    <span class="pun">}</span><span class="pln">
    location </span><span class="pun">~*</span> <span class="pun">^.+.(</span><span class="pln">jpg</span><span class="pun">|</span><span class="pln">jpeg</span><span class="pun">|</span><span class="pln">gif</span><span class="pun">|</span><span class="pln">css</span><span class="pun">|</span><span class="pln">png</span><span class="pun">|</span><span class="pln">js</span><span class="pun">|</span><span class="pln">ico</span><span class="pun">|</span><span class="pln">xml</span><span class="pun">|</span><span class="pln">htm</span><span class="pun">|</span><span class="pln">txt</span><span class="pun">|</span><span class="pln">swf</span><span class="pun">|</span><span class="pln">cur</span><span class="pun">)</span><span class="pln">$ </span><span class="pun">{</span><span class="pln">
        access_log off</span><span class="pun">;</span><span class="pln">
        expires    </span><span class="lit">1w</span><span class="pun">;</span>
    <span class="pun">}</span>


    <span class="com">#error_page</span><span class="pln">
    error_page </span><span class="lit">400</span> <span class="pun">/</span><span class="typ">ErrorPages</span><span class="pun">/</span><span class="lit">400.html</span><span class="pun">;</span><span class="pln">
    error_page </span><span class="lit">403</span> <span class="pun">/</span><span class="typ">ErrorPages</span><span class="pun">/</span><span class="lit">403.html</span><span class="pun">;</span><span class="pln">
    error_page </span><span class="lit">404</span> <span class="pun">/</span><span class="typ">ErrorPages</span><span class="pun">/</span><span class="lit">404.html</span><span class="pun">;</span><span class="pln">
    error_page </span><span class="lit">502</span> <span class="pun">/</span><span class="typ">ErrorPages</span><span class="pun">/</span><span class="lit">502.html</span><span class="pun">;</span><span class="pln">
    location </span><span class="pun">~</span> <span class="str">/ErrorPages/</span><span class="pun">(</span><span class="lit">400</span><span class="pun">|</span><span class="lit">401</span><span class="pun">|</span><span class="lit">403</span><span class="pun">|</span><span class="lit">404</span><span class="pun">|</span><span class="lit">405</span><span class="pun">|</span><span class="lit">502</span><span class="pun">|</span><span class="lit">503</span><span class="pun">)</span><span class="pln">\.html$
    </span><span class="pun">{</span><span class="pln">
        root </span><span class="pun">/</span><span class="pln">home</span><span class="pun">/</span><span class="pln">wwwroot</span><span class="pun">/</span><span class="pln">lnmp02</span><span class="pun">/</span><span class="pln">domain</span><span class="pun">/</span><span class="pln">bbs</span><span class="pun">/</span><span class="pln">web</span><span class="pun">;</span>
    <span class="pun">}</span><span class="pln">

    location </span><span class="pun">~</span> <span class="pun">.*</span><span class="pln">\.php$
    </span><span class="pun">{</span>
        <span class="com"># 如果你在Ubuntu 或者 LinuxMint 上安装,可能如此</span><span class="pln">
        fastcgi_pass  unix</span><span class="pun">:</span><span class="str">/run/</span><span class="pln">php7</span><span class="pun">.</span><span class="lit">0</span><span class="pun">-</span><span class="pln">fpm</span><span class="pun">.</span><span class="pln">sock</span><span class="pun">;</span><span class="pln">
        fastcgi_index index</span><span class="pun">.</span><span class="pln">php</span><span class="pun">;</span><span class="pln">
        include fcgi</span><span class="pun">.</span><span class="pln">conf</span><span class="pun">;</span><span class="pln">
        fastcgi_param DOCUMENT_ROOT  </span><span class="pun">/</span><span class="pln">home</span><span class="pun">/</span><span class="pln">wwwroot</span><span class="pun">/</span><span class="pln">html</span><span class="pun">/你的域名;</span><span class="pln">
        fastcgi_param SCRIPT_FILENAME  </span><span class="pun">/</span><span class="pln">home</span><span class="pun">/</span><span class="pln">wwwroot</span><span class="pun">/</span><span class="pln">html</span><span class="pun">/你的域名</span><span class="pln">$subdomain$fastcgi_script_name</span><span class="pun">;</span>
    <span class="pun">}</span><span class="pln">

    location </span><span class="pun">~</span> <span class="pun">.*</span><span class="pln">\.</span><span class="pun">(</span><span class="pln">gif</span><span class="pun">|</span><span class="pln">jpg</span><span class="pun">|</span><span class="pln">jpeg</span><span class="pun">|</span><span class="pln">png</span><span class="pun">|</span><span class="pln">bmp</span><span class="pun">|</span><span class="pln">swf</span><span class="pun">|</span><span class="pln">flv</span><span class="pun">|</span><span class="pln">mp3</span><span class="pun">|</span><span class="pln">wma</span><span class="pun">)</span><span class="pln">$
    </span><span class="pun">{</span><span class="pln">
        expires      </span><span class="lit">30d</span><span class="pun">;</span>
    <span class="pun">}</span><span class="pln">

    location </span><span class="pun">~</span> <span class="pun">.*</span><span class="pln">\.</span><span class="pun">(</span><span class="pln">js</span><span class="pun">|</span><span class="pln">css</span><span class="pun">)</span><span class="pln">$
    </span><span class="pun">{</span><span class="pln">
        expires      </span><span class="lit">12h</span><span class="pun">;</span>
    <span class="pun">}</span>
        <span class="com"># 不要日志</span><span class="pln">
        access_log off</span><span class="pun">;</span><span class="pln">
        error_log </span><span class="pun">/</span><span class="pln">dev</span><span class="pun">/</span><span class="kwd">null</span><span class="pun">;</span>
<span class="pun">}</span>

 

按自己的 Nginx 和网站的路径配置,改写下上面的规则,然后在使用 Nginx 检查重写规则后,重载即可。

you may modify the above rules according your Nginx and the directory of your IPS ,then check rules via Nginx, and reload it.

<span class="pln">sudo nginx -t
sudo nginx reload</span>
 

除特别注明外,本站所有文章均为站长帮原创,转载请注明出处来自http://www.zzbang.cn/cms/2722.html

关于
站长帮是一个为站长服务的网站

发表评论

表情 格式

  1. 不错啊

    zzbang 博 主 3个月前 (03-02) [0] [0]

登录

忘记密码 ?

您也可以使用第三方帐号快捷登录

切换登录

注册

扫一扫二维码分享