homepage Welcome to WebmasterWorld Guest from 54.242.200.172
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Accredited PayPal World Seller

Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
Problem chaining rewriterules
Zacharias




msg:3422405
 2:47 am on Aug 15, 2007 (gmt 0)

Hi,

I am having problems using more than 8 variables and I see that apache can only handle 8 and it is possible to chain rewriterules together.

I read a post on this forum where this example was given

#rewriterule ^product([^-]+)-([^-]+)-([^-]+)-([^-]+)-([^-]+)-([^-]+)-([^-]+)-([^-]+)-(.+)$ /script.php.$9?v1=$1&v2=$2&v3=$3&v4=$4&v5=$5&v6=$6&v7=$7&v8=$8 [C]
#rewriterule ^script\.php\.([^-]+)-([^-]+)-([^-]+)-([^-]+)no dash$ /script.php?v9=$1&v10=$2&v11=$3&v12=$4& [QSA,L]

I am trying to use the same logic with the beneath rule. (This rule would normally work, were it not for that pesky apache limitation!)

RewriteRule ^/?([-a-zA-Z0-9_\-]+)/([-a-zA-Z0-9_\-]+)/([a-zA-Z0-9]+)-([a-zA-Z0-9_\-]+)/([a-zA-Z0-9]+)-([a-zA-Z0-9_\-]+)/([a-zA-Z0-9]+)-([a-zA-Z0-9_\-]+)/([a-zA-Z0-9]+)-([a-zA-Z0-9_\-]+)/?$ index.php?sectionnameurl=$1&categorynameurl=$2&geta=$3&geturla=$4&getb=$5&geturlb=$6&getc=$7&geturlc=$8&getd=$9&geturld=$10 [NC]

Here is my attempt at converting the above rewriterule to the chained logic in the first example.

RewriteRule ^/?([a-zA-Z0-9_\-]+)/([a-zA-Z0-9_\-]+)/([a-zA-Z0-9]+)-([a-zA-Z0-9_\-]+)/([a-zA-Z0-9]+)-([a-zA-Z0-9_\-]+)/([a-zA-Z0-9]+)-([a-zA-Z0-9_\-]+)/$ index.php.$9?sec=$1&cat=$2&geta=$3&geturla=$4&getb=$5&geturlb=$6&getc=$7&geturlc=$8 [C]
RewriteRule ^([a-zA-Z0-9]+)-([a-zA-Z0-9_\-]+)$ /index.php?getd=$1&geturld=$2 [QSA,L]

I cant seem to get it to work no matter how hard i try :(

Any help is much appreciated

Cheers

Z

 

Zacharias




msg:3422849
 2:51 pm on Aug 15, 2007 (gmt 0)

Still really struggling with this.

I get a 404 error no matter which combination I use.

Should I move this work out of htaccess and into my script?

The only problem with this is that I will still run out of variables at some point, because there are more (around 12 in total)

Really appreciate any advice as to how to tackle this.

Cheers

Z

jdMorgan




msg:3422926
 4:07 pm on Aug 15, 2007 (gmt 0)

The pattern of the second rule must match the URL as rewritten by the first rule, otherwise, it will never be applied. Look at the example you worked from: The first rule rewrites to an intermediate URL (script.php), puts any name/values that won't fit into the first eight variables ($1-$8) into variable $9 and then back-references $9 in the substitution URL, so that the second rule can parse those additional name/values.

Note that "script.php" need not be a real URL or a real file -- it is just used as a unique temporary name while we step through the chained rules.

Jim

Zacharias




msg:3423087
 6:07 pm on Aug 15, 2007 (gmt 0)

Thanks a lot for the help with this.

There is really not a lot of information about how to do things like this in apache.

Very much appreciated

Z

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.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved