Forums / Cotonti / Support / mod_rewrite HELP needed

url rewriting in .htaccess to create SEO subdomains and subfolders

donP
#23698 2010-03-22 02:35
I've tried, but, as I'd imagined, nothing works anymore, cause with a positive condition instead of a negative one, it will skip all following Rewriting rules...
The positive one works well, but it seems I can't tell the last rewriterule to capture the right backreference to transform http:/maincat.sangelo.net/ in list.php?c=maincat

Added 4 hours 30 minutes later:

Eureka! I finally found it! :)

RewriteCond %{HTTP_HOST} ^www\.sangelo\.net$ [NC]
RewriteRule . - [S=8]
RewriteRule ^([a-z\-]+)/([a-z\-]+)/([0-9]+)\.html$ page.php?id=$3 [NC,QSA,L]
RewriteRule ^([a-z\-]+)/([a-z\-]+)/([a-z0-9_-]+)\.html$ page.php?al=$3 [NC,QSA,L]
RewriteRule ^([a-z\-]+)/([0-9]+)\.html$ page.php?id=$2 [NC,QSA,L]
RewriteRule ^([a-z\-]+)/([a-z0-9_-]+)\.html$ page.php?al=$2 [NC,QSA,L]
RewriteRule ^([0-9]+)\.html$ page.php?id=$1 [NC,QSA,L]
RewriteRule ^([a-z0-9_-]+)\.html$ page.php?al=$1 [NC,QSA,L]
RewriteRule ^([a-z\-]+)/([a-z\-]+)/?$ list.php?c=$2 [NC,QSA,L]
RewriteRule ^([a-z\-]+)/?$ list.php?c=$1 [NC,QSA,L]

RewriteCond %{HTTP_HOST} ^(articles|downloads|news|docs)\.sangelo\.net$ [NC]
RewriteRule ^([a-z\-]*)$ list.php?c=%1 [QSA,NC,NE,L]

Many thanks to Koradhil for his assistence and support! ;)
And to my patience to try all possible combination and reading millions of pages about Apache mod_rewriting!

P.S. I've added page.php?id=ID rule and also modified list rules to match either ending slash form and form without ending slash.
I've also restricted cat and subcat RegEx to lowercase alphabetical characters to speedup Server.
in [color=#729FCF][b]BLUES[/b][/color] I trust

Dit bericht is bewerkt door donP (2010-03-22 07:05, 15 jaren ago)