htaccess 中的重写规则

RewriteRules in htaccess

我在 .htaceess 中有这段代码:

Options +FollowSymlinks 
RewriteEngine On
RewriteBase /
RewriteRule aa/(.+)   [QSA,L]
RewriteRule .+  index.php?username=[=10=] [L,QSA]

index.php内容:

<?php
var_dump($_GET);
?>

这是文件结构:

root
|
|_____css
|      |____ style.css
|
|_____ .htaccess
|_____ index.php

我想要当类型 http://domain/aa/css/style.css 重定向到 /css/style.css 对于我输入的所有其他网址,即:http://domain/test 重定向到 /index.php?username=test

现在,当我键入 http://domain/test 时,效果很好。但是当我输入 http://domain/aa/css/style.css 而不是 style.css 时,浏览器会显示:

array(1) { ["username"]=> string(13) "css/style.css" }

现在如何将 .htaccess 更改为一切正常?

您可以使用:(见下面的评论)

Options +FollowSymlinks 
RewriteEngine On
RewriteBase /

RewriteRule aa/(.+)  [NC,L]

RewriteCond %{THE_REQUEST} !/aa/ [NC]
RewriteRule .+ index.php?username=[=10=] [L,QSA]