saeid ezzati
saeid ezzati

Reputation: 891

RewriteRules in htaccess

I have this code in .htaceess :

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

index.php content:

<?php
var_dump($_GET);
?>

and this is structure of files:

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

I want when type http://domain/aa/css/style.css redirects to /css/style.css and for every other urls that me type ie: http://domain/test redirects to /index.php?username=test

now when I type http://domain/test its work good. but when I type http://domain/aa/css/style.css instead of style.css browser shows me this:

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

now how change .htaccess to every thing works right ?

Upvotes: 1

Views: 80

Answers (1)

anubhava
anubhava

Reputation: 784948

You can use: (see comments below)

Options +FollowSymlinks 
RewriteEngine On
RewriteBase /

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

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

Upvotes: 2

Related Questions