.htaccess 在htaccess中重写规则
我在.htaceess中有此代码:.htaccess 在htaccess中重写规则,.htaccess,mod-rewrite,.htaccess,Mod Rewrite,我在.htaceess中有此代码: Options +FollowSymlinks RewriteEngine On RewriteBase / RewriteRule aa/(.+) $1 [QSA,L] RewriteRule .+ index.php?username=$0 [L,QSA] index.php内容: <?php var_dump($_GET); ?> 当type重定向到/css/style.css 对于me键入的每一个其他URL,即:重定向到/inde
Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteRule aa/(.+) $1 [QSA,L]
RewriteRule .+ index.php?username=$0 [L,QSA]
index.php内容:
<?php
var_dump($_GET);
?>
当type重定向到/css/style.css
对于me键入的每一个其他URL,即:重定向到/index.php?username=test
现在,当我输入时,效果很好。但当我键入而不是样式时,css浏览器会显示以下内容:
array(1) { ["username"]=> string(13) "css/style.css" }
现在,如何更改.htaccess使每件事都正常工作?您可以使用:(请参阅下面的注释)
在第二个重写规则之前添加RewriteCond:RewriteCond%{REQUEST_FILENAME}-f RewriteCond%{REQUEST_FILENAME}-重写规则+index.php?用户名=$0[L,QSA]现在我想知道用户何时进入
http://domain/css/style.css
即使该目录和文件存在,htaccess也会将其重写为http://domain/index.php?username=css/style.css
且仅当转到http://domain/aa/css/style.css
将其重写为http://domain/css/style.css
。现在请引导我。好的,我删除了这两个rewritecond语句,但这次当我转到http://domain/aa/css/style.css
在第一个rewriterule语句中匹配后,[L]开关不停止重写,输出发送到第二个rewriterule,最终输出url为http://domain/index.php?username=css/style.css
。但是为什么?好吧,我改变了它,工作正常。但现在我想知道什么是[L]旗。在匹配后的第一个rewriterule语句中,[L]标志必须停止重写过程。但是我没有这样做!为什么?没有L
不会在规则下停止。它只会停止当前的规则。让我们。
array(1) { ["username"]=> string(13) "css/style.css" }
Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteRule aa/(.+) $1 [NC,L]
RewriteCond %{THE_REQUEST} !/aa/ [NC]
RewriteRule .+ index.php?username=$0 [L,QSA]