首页  >  文章  >  后端开发  >  Apache & nginx 的地址重写 url_rewrite,省略 indexphp

Apache & nginx 的地址重写 url_rewrite,省略 indexphp

WBOY
WBOY原创
2016-07-28 08:29:091009浏览

<code><span>Apache</span> url_rewrite:

<span><span>LoadModule</span></span> rewrite_module modules/mod_rewrite.so
<span><ifmodule mod_rewrite.c></ifmodule></span><span><span>RewriteEngine</span></span><span>on</span><span>RewriteBase</span> /

      <span><span>RewriteCond</span></span><span>%{REQUEST_FILENAME}</span> !-d
      <span><span>RewriteCond</span></span><span>%{REQUEST_FILENAME}</span> !-f
      <span><span>RewriteRule</span></span> ^(.*)$ index.php/<span>$1</span><span> [QSA,PT,L]</span><span>#RewriteRule ^(.*)$ index.php?$1 [QSA,L]</span><span></span></code>
<code><span>Nginx</span> url_rewrite:

location / {
    <span>if</span> (!-e <span>$request_filename</span>) {
        <span>#一级目录</span>
        rewrite ^<span>/(.*)$ /index</span>.php/<span>$1</span> last;

        <span>#二级目录</span>
        rewrite ^<span>/public/</span>(.*)<span>$ </span>/public/index.php/<span>$1</span> last;
    }
}</code>
').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });

以上就介绍了 Apache & nginx 的地址重写 url_rewrite,省略 indexphp,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn