Forum Moderators: phranque
I cant seem to get these two rules to work together.
The first is the actual page and the second is the paginated page.
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_/-]+)/([a-zA-Z0-9]+)-([a-zA-Z0-9_/-]+)/$ script.php.$9?sec=$1&cat=$2&geta=$3&geturla=$4&getb=$5&geturlb=$6&getc=$7&geturlc=$8 [C]
rewriterule ^script\.php\.([a-zA-Z0-9_/-]+)/([a-zA-Z0-9]+)-([a-zA-Z0-9_/-]+)/([a-zA-Z0-9]+)-([a-zA-Z0-9_/-]+)/$ /testtd/index.php?var=$1&getd=$2&geturld=$3&gete=$4&geturle=$5 [QSA,L]
#page
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_/-]+)/([a-zA-Z0-9]+)-([a-zA-Z0-9_/-]+)/$ script.php.$9?sec=$1&cat=$2&geta=$3&geturla=$4&getb=$5&geturlb=$6&getc=$7&geturlc=$8 [C]
rewriterule ^script\.php\.([a-zA-Z0-9_/-]+)/([a-zA-Z0-9]+)-([a-zA-Z0-9_/-]+)/([a-zA-Z0-9]+)-([a-zA-Z0-9_/-]+)/_([0-9]+)/$ /testtd/index.php?var=$1&getd=$2&geturld=$3&gete=$4&geturle=$5&page=$6 [QSA,L]
Is it because the first part in the chain, the condition is met and therefore only the 1st rule works?
Cheers
Z
I felt it might have something to do with the first part in the chain condition being met in the first rule and therefore the first rule applying to both sets of pages, no?
I am wondering if it is possible to use a rewritecond to check if a parameter or character (in my case an underscore) exists in the query string and then append &page= to the end of the rewrite rule. This would achieve what I want,however im not sure how to write it.
Any help is much appreciated
cheers
z
Generalizing, you cannot use a character as a substring separator while also using it inside the substring to be separated.
You also have too many parentheses in the the first rule of both chained sets. You may use nine pairs, and no more. Use the ninth pair to grab *everything* that won't fit in the first eight pairs.
You can make good use of the [NC] flag to simplify your patterns, and make them somewhat more tolerable to read and interpret for those brave souls who care to undertake the task... The [NC] flag makes the pattern-matching case-insensitive, which means you can use just [A-Z] or [a-z] in each of the subpatterns, instead of having to use [A-Za-z] in each one.
Cleaning up the separator/parameter and too-many-parentheses problems, adding the [NC] flag, putting the rules in order, and tidying-up in general, I'd recommend something like this:
# paged
RewriteRule ^([a-z0-9_-]+)/([a-z0-9_-]+)/([a-z0-9]+)-([a-z0-9_-]+)/([a-z0-9]+)-([a-z0-9_-]+)/([a-z0-9]+)-([a-z0-9_-]+)/([a-z0-9]+-[a-z0-9_-]+/[a-z0-9]+-[a-z0-9_-]+)/$ tempurl/$9?sec=$1&cat=$2&geta=$3&geturla=$4&getb=$5&geturlb=$6&getc=$7&geturlc=$8 [NC,C]
RewriteRule ^tempurl/([a-z0-9_-]+)/([a-z0-9]+)-([a-z0-9_-]+)/([a-z0-9]+)-([a-z0-9_-]+)/_([0-9]+)$ /testtd/index.php?var=$1&getd=$2&geturld=$3&gete=$4&geturle=$5&page=$6 [NC,QSA,L]
#
# non-paged
RewriteRule
^([a-z0-9_-]+)/([a-z0-9_-]+)/([a-z0-9]+)-([a-z0-9_-]+)/([a-z0-9]+)-([a-z0-9_-]+)/([a-z0-9]+)-([a-z0-9_-]+)/([a-z0-9]+-[a-z0-9_-]+/[a-z0-9]+-[a-z0-9_-]+)/$ tempurl/$9?sec=$1&cat=$2&geta=$3&geturla=$4&getb=$5&geturlb=$6&getc=$7&geturlc=$8 [NC,C]
RewriteRule ^tempurl/([a-z0-9_/-]+)/([a-z0-9]+)-([a-z0-9_/-]+)/([a-z0-9]+)-([a-z0-9_/-]+)$ /testtd/index.php?var=$1&getd=$2&geturld=$3&gete=$4&geturle=$5 [NC,QSA,L]
I may have typoed or fat-finger-deleted something unintentionally. Check carefully and test thoroughly.
Jim