Go Back   CodingForums.com > :: Server side development > Apache configuration

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-02-2012, 05:44 AM   PM User | #1
jdblewitt
New Coder

 
Join Date: Sep 2006
Posts: 84
Thanks: 47
Thanked 0 Times in 0 Posts
jdblewitt is an unknown quantity at this point
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.
jdblewitt is offline   Reply With Quote
Old 02-02-2012, 03:38 PM   PM User | #2
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,645
Thanks: 4
Thanked 2,450 Times in 2,419 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
.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.
Fou-Lu is offline   Reply With Quote
Users who have thanked Fou-Lu for this post:
jdblewitt (02-02-2012)
Old 02-02-2012, 08:05 PM   PM User | #3
jdblewitt
New Coder

 
Join Date: Sep 2006
Posts: 84
Thanks: 47
Thanked 0 Times in 0 Posts
jdblewitt is an unknown quantity at this point
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?
jdblewitt is offline   Reply With Quote
Old 02-02-2012, 08:17 PM   PM User | #4
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,645
Thanks: 4
Thanked 2,450 Times in 2,419 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
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.
Fou-Lu is offline   Reply With Quote
Users who have thanked Fou-Lu for this post:
jdblewitt (02-02-2012)
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:00 AM.


Advertisement
Log in to turn off these ads.