Foren / Cotonti / Support / mod_rewrite HELP needed

url rewriting in .htaccess to create SEO subdomains and subfolders

donP
#23631 18. März 2010, 17:56
tensh:
Also, I think that the last example might have a typo... no $ at the end.
It's irrilevant, it works well also without $ at the end.
tensh:
It's because there's no reflection of the category structure in lists - you have two variables in htaccess rule and only one variable in list.php, how do you imagine script should act in this case?
I'm only trying to read the last variable in rewrite rule. Other variables could also been filled with casual values (the right strings come from function-custom.php, that I've already written successfully), 'cause the really relevant value to call the appropriate structure-code for list.php?c=catcode is only the last value included between / and /, with a backreference, as you can see in the rules written by Trustmaster:
### Combined pages & lists ###
# Level 3
RewriteRule ^(articles|downloads|news|docs)/([a-z\-]+)/([a-z\-]+)/([0-9]+) page.php?id=$4 [QSA,NC,NE,L]
RewriteRule ^(articles|downloads|news)/([a-z\-]+)/([a-z\-]+)/add$ page.php?m=add&c=$3 [QSA,NC,NE,L]
RewriteRule ^(articles|downloads|news|docs)/([a-z\-]+)/([a-z\-]+)/([a-zA-Z0-9\-_]+) page.php?al=$4 [QSA,NC,NE,L]
RewriteRule ^(articles|downloads|news)/([a-z\-]+)/([a-z\-]+)/ list.php?c=$3 [QSA,NC,NE,L]

# Level 2
RewriteRule ^(articles|downloads|news|docs)/([a-z\-]+)/([0-9]+) page.php?id=$3 [QSA,NC,NE,L]
RewriteRule ^(articles|downloads|news)/([a-z\-]+)/add$ page.php?m=add&c=$2 [QSA,NC,NE,L]
RewriteRule ^(articles|downloads|news|docs)/([a-z\-]+)/([a-zA-Z0-9\-_]+) page.php?al=$3 [QSA,NC,NE,L]
RewriteRule ^(articles|downloads|news)/([a-z\-]+)/ list.php?c=$2 [QSA,NC,NE,L]

# Level1
RewriteRule ^(articles|downloads|news|docs)/([0-9]+) page.php?id=$2 [QSA,NC,NE,L]
RewriteRule ^(articles|downloads|news|docs)/add$ page.php?m=add&c=$1 [QSA,NC,NE,L]
RewriteRule ^(articles|downloads|news|docs)/([a-zA-Z0-9\-_]+) page.php?al=$2 [QSA,NC,NE,L]
RewriteRule ^(articles|downloads|news|docs)/ list.php?c=$1 [QSA,NC,NE,L]

With that rules, for example, you can write in browser url adress bar:
www.sangelo.net/cat1/subcat2/ and however you'll go to list.php?c=subcat2, cause the rule tells the Server intepreter to read the last backreference and use it to call the appropriate subcategory with list.php?c=subcatcode
tensh:
See the docs for classic category example, adjust it to reflect subdomain.
As you can see, this is what I have done (but adding a RewriteCond, cause to change the domain part of url that's the only way).
in [color=#729FCF][b]BLUES[/b][/color] I trust