PermanentRedirection exception

Hello,


I have a basic set up  with a folder "folder":
www.example.org/html/folder

Under this folder, I have two more folders:
html/folder/aaa
html/folder/bbb

Now, the problem is that I want everybody who navigates to a page under /html/folder/aaa to be redirected to /html/folder/bbb

PermanentRedirect /html/folder/aaa http://www.example.com/html/folder/bbb/index.php
Easy!

Except that I want people to be still able to navigate to a folder UNDER aaa -  
i.e., I navigate to :

http://www.example.com/html/folder/aaa/index.php                           I get redirected!

http://www.example.com/html/folder/aaa/stay/index.php                  I don't get redirected!

Something like:
PermanentRedirect /html/folder/aaa(!stay)       http://www.example.com/html/folder/bbb???

Is this possible, or must I resort to using a PermanentRedirect for everything except that stay folder??
Thats a lot of work, and not as pretty a solution.

Thank you for your help, as always.
Best regards,
noshankusAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
caterham_wwwConnect With a Mentor Commented:
-> httpd.conf
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/html/folder/aaa/stay
RewriteRule ^(/html/folder)/aaa/(.*)$ $1/bbb/$2 [R=301,L]

-> .htaccess
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/html/folder/aaa/stay
RewriteRule ^(html/folder)/aaa/(.*)$ /$1/bbb/$2 [R=301,L]
0
 
ahoffmannCommented:
RewriteCond %{REQUEST_URI} ^/html/folder/aaa/[^/]*$
RewriteRule ^(/html/folder)/aaa/(.*)$ $1/bbb/$2 [R=301,L]
0
 
noshankusAuthor Commented:
Hi,

how does that exclude the folder "stay"?
Considering that there are other folders at the same level as "stay" that I want to redirect.
0
 
noshankusAuthor Commented:
Fantastic! Thank you very much =)
0
All Courses

From novice to tech pro — start learning today.