Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

1 Answer 1

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

 
discard

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.