PermanentRedirection exception

Posted on 2005-05-06
Last Modified: 2012-05-05

I have a basic set up  with a folder "folder":

Under this folder, I have two more folders:

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

Except that I want people to be still able to navigate to a folder UNDER aaa -  
i.e., I navigate to :                           I get redirected!                  I don't get redirected!

Something like:
PermanentRedirect /html/folder/aaa(!stay)

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,
Question by:noshankus
    LVL 51

    Expert Comment

    RewriteCond %{REQUEST_URI} ^/html/folder/aaa/[^/]*$
    RewriteRule ^(/html/folder)/aaa/(.*)$ $1/bbb/$2 [R=301,L]

    Author Comment


    how does that exclude the folder "stay"?
    Considering that there are other folders at the same level as "stay" that I want to redirect.
    LVL 27

    Accepted Solution

    -> 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]

    Author Comment

    Fantastic! Thank you very much =)

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    In my time as an SEO for the last 2 years and in the questions I have assisted with on here I have always seen the need to redirect from non-www urls to their www versions. For instance redirecting ( to http…
    As Wikipedia explains 'robots.txt' as -- the robot exclusion standard, also known as the Robots Exclusion Protocol or robots.txt protocol, is a convention to prevent cooperating web spiders and other web robots from accessing all or part of a websit…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now