1

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

2

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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