Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Sep 2006
    Posts
    84
    Thanks
    47
    Thanked 0 Times in 0 Posts

    RewriteBase wilcard?

    I have a directory...

    /book-clubs

    within this directory I have many many subdirectories. My question is do I have to make a htaccess for each subdirectory? I want to make...

    http://www.bookclubshop.com/book-clu...section=review

    http://www.bookclubshop.com/book-clubs/doubleday/review

    Can I do this w/o putting a rewrite rule in the doubleday directory?

    I would like to just have one rewrite rule in /book-clubs and somehow make the rewritebase /book-clubs/(wildcard) and then have the rule....can someone let me know if this is possible....or if there is a way to accomplish this? Thanks.

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    .htaccess cascades. You can put the rule set into the root and have it apply to all sub directories. IMO its more manageable to work directly off of a single cascading .htaccess than that of a subdirectory.
    A simple match of ^/book-clubs/doubleday/(.*)$ /path/to/index.php?section=$1 will work fine.

  • Users who have thanked Fou-Lu for this post:

    jdblewitt (02-02-2012)

  • #3
    New Coder
    Join Date
    Sep 2006
    Posts
    84
    Thanks
    47
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Fou-Lu View Post
    .htaccess cascades. You can put the rule set into the root and have it apply to all sub directories. IMO its more manageable to work directly off of a single cascading .htaccess than that of a subdirectory.
    A simple match of ^/book-clubs/doubleday/(.*)$ /path/to/index.php?section=$1 will work fine.
    Thanks so much...that's great news! So I can have just one in the root....what would the rule look like if I wanted all subdirectories in /book-clubs/ would it be..

    ^/book-clubs/(.*)$ index.php?section=$1

    So then this would work for say...

    http://www.bookclubshop.com/book-clu...section=review

    as well as the doubleday subdirectory?

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    It keeps cascading yeah. But your ruleset will need refinement. As is, matching the .* will pull the subdirectories and provide them as matches to the ?section=$1 which may or may not be the intent. You need to be careful as well, if you redirect to a matched directories index file, it will cyclically redirect to that index likely causing a 500. So you'll want to look at using RewriteCond as well as RewriteRule to make it ignore certain things.

  • Users who have thanked Fou-Lu for this post:

    jdblewitt (02-02-2012)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •