Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using in my cms with a pre-defined htaccess, as the following:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?%{QUERY_STRING} [L]

I want to update the url in order to remove 2 "sub directories":

from /en/top/solutions/?id=1 to /solutions/?id=1
from /en/top/about/?othervar=1 to /about/?othervar=1

this one of the things i did so far:

RewriteRule ^en/top/ /$1 [L,R=301]  

I could not get it to work. Thanks

share|improve this question

The $1 means "use the first capture part of the original url". In order to capture a part of the original URL, you need to use a parenthesis to capture it in. Like this:

RewriteRule ^/en/top/(.*) /$1 [QSA]

This means "take anything that starts with /en/top/, then capture what follows and put that into the variable $1. Rewrite to just the $1 variable and append the original query string.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.