homepage Welcome to WebmasterWorld Guest from 54.227.40.166
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
Using one rewritecond on several rewrite rules
Zacharias




msg:3421582
 10:16 am on Aug 14, 2007 (gmt 0)

Hi,

I have these rules and am going to have to create many more if I cant find an alternative.

I am trying to match every permutation/combination of "folder1", "folder2" and "folder3"

RewriteRule ^/?([-a-zA-Z0-9_\-]+)/([-a-zA-Z0-9_\-]+)/folder1-([a-zA-Z0-9_\-]+)/folder2-([a-zA-Z0-9_\-]+)/folder3-([-a-zA-Z0-9_\-]+)/?$
index.php?url1=$1&url2=$2&folder1=$3&folder2=$4&folder3=$5 [NC]

RewriteRule ^/?([-a-zA-Z0-9_\-]+)/([-a-zA-Z0-9_\-]+)/folder2-([a-zA-Z0-9_\-]+)/folder1-([a-zA-Z0-9_\-]+)/folder3-([-a-zA-Z0-9_\-]+)/?$
index.php?url1=$1&url2=$2&folder2=$3&folder1=$4&folder3=$5 [NC]

RewriteRule ^/?([-a-zA-Z0-9_\-]+)/([-a-zA-Z0-9_\-]+)/folder3-([-a-zA-Z0-9_\-]+)/folder2-([a-zA-Z0-9_\-]+)/folder1-([a-zA-Z0-9_\-]+)/?$
index.php?url1=$1&url2=$2&folder3=$3&folder2=$4&folder1=$5 [NC]

I am using my application to detect the word "folder(x)-" in the URL and then serve the appropriate content.

Is there any way that these rules can be combined into several rewrite conditions?

I am a bit daunted by the fact that I have more "folders" and could perhaps have thousands of combinations and therefore would have to write thousands of rewrite rules to match them.

Thanks in advance for any guidance

[edited by: Zacharias at 10:26 am (utc) on Aug. 14, 2007]

 

jdMorgan




msg:3422091
 6:53 pm on Aug 14, 2007 (gmt 0)

Consider this:

How about using a single rule to match *any* of URLs in the format you've shown, and rewrite all of them to your script. You can then modify the script to check the 'validity' of each "folder" value against your database, handle the request if it's valid, or return an error status if not.

In other words, move the heavy lifting into the script, where you have better equipment readily available to handle all the contingencies.

Jim

Zacharias




msg:3422399
 2:40 am on Aug 15, 2007 (gmt 0)

Thanks for the advice, it really helped :)

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved