Hello,

I have a problem with redirections in .htaccess... Maybe anyone can help me to solve it...

We have a website. Some times ago, we build a new release of it to simplify some pages / structures and we put it in the server.

This website have many roles like members, collectors, brands, stores, associations and medias. Brands, stores, associations and medias can have two status : partner or non-partner.

Each role has it own area.
- Brands and associations can be browsed on {user-name}/{page or content title}
- Other roles can be browsed on {uid}/{user-name}/{page or content title}

If a user is partner, he has lot of pages, like this :

- (/{uid})/{user-name}/home
- (/{uid})/{user-name}/profile
- (/{uid})/{user-name}/history
- (/{uid})/{user-name}/collections
- (/{uid})/{user-name}/collections/{collection-title}
- (/{uid})/{user-name}/news
- (/{uid})/{user-name}/news/{news-title}
- ...
- ...

Now if a user is not partner, he only have one page

- (/{uid})/{user-name}/home

with all informations.

On the old website, all users have /profile, /collections, /news, etc...
But on the new website, only partners have lot of pages, like explained above.

My goal is to redirect all "non-existing" /profile, /collections, etc... to the matching /home page.

If I write this :

RewriteRule my-non-partner-brand-name/profile$ http://www.mysite.com/my-non-partner-brand-name/home [R=301,L]

It work correctly. But I don't want to write thousand rules to make all working. The second problem is if the /profile page exists, I don't need to redirect user.

I think about a cond/rule like this (pseudo code...), but don't find the correct way (I'm really not good with regex/rewrite rules) :

RewriteCond ^(a-zA-Z0-9)/profile$ !-U
RewriteRule ^(.*)$ http://www.mysite.com/$1/home [R=301,L]

But unfortunately, it don't work as expected... I know that my code is wrong because I'm a newbie with regex and never really understood it, but I think it's maybe possible to do it...

If anyone can help me to solve this problem it would be great.

Thanks in advance for any suggestion about that. (and sorry for my bad english)