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