| Author | Message |
Koradhil Posts: 413 http://www.ghengeveld.nl Location: Netherlands Rotterdam Occupation: Webdeveloper Age: 22 | #31 2010-03-06 21:20 |
| Using a custom function for URL rewriting is a very powerful feature, but requires quite some skill and knowledge to apply correctly. I've never used it myself, so it's beyond my knowledge, even though I use the rewriting system a lot. Added 24 minutes later: Come to think of it, I don't think it's possible to rewrite the main url, for editing the subdomain. You can still do it through .htaccess, but that won't really rewrite the url, only redirect the visitor so it seems to him there was a subdomain specified. - Cotonti rewrite to www.domain.com/cat/subcat - .htaccess rewrite www.domain.com/cat/subcat to cat.domain.com/subcat, with [R=301] specified - .htaccess rewrite cat.domain.com/subcat to www.domain.com/list.php?c=subcat without [R=301] This post was edited by Koradhil (2010-03-06 21:45, 185 days ago) | |
donP Posts: 171 http://www.sangelo.net Location: Italy Rozzano (MI) Occupation: Teacher, Musician Age: 37 | #32 2010-03-07 15:19 |
| I was able to modify function.custom.php like this: function list_url_structure(&$args)
{
global $sed_cat;
$url = str_replace('.', '/', $sed_cat[$args['c']]['path']).'/';
unset($args['c']);
$subdomain = substr($url, 0, strpos($url,"/"));
$restofurl = substr($url, strpos($url,"/")+1);
return "http://".$subdomain.".sangelo.net/".$restofurl;
}Now I would find anyone to help me modifying .htacces from # Level 3 RewriteRule ^(Parrocchia|Oratorio|SocietaSportiva|Scout|RnB|links|ECOComunita|news|Diari)/([a-z\-]+)/([a-z\-]+)/([0-9]+)\.html page.php?id=$4 [QSA,NC,NE,L] RewriteRule ^(Parrocchia|Oratorio|SocietaSportiva|Scout|RnB|links|ECOComunita|news|Diari)/([a-z\-]+)/([a-z\-]+)/add$ page.php?m=add&c=$3 [QSA,NC,NE,L] RewriteRule ^(Parrocchia|Oratorio|SocietaSportiva|Scout|RnB|links|ECOComunita|news|Diari)/([a-z\-]+)/([a-z\-]+)/([a-zA-Z0-9\-_]+)\.html page.php?al=$4 [QSA,NC,NE,L] RewriteRule ^(Parrocchia|Oratorio|SocietaSportiva|Scout|RnB|links|ECOComunita|news|Diari)/([a-z\-]+)/([a-z\-]+)/ list.php?c=$3 [QSA,NC,NE,L] # Level 2 RewriteRule ^(Parrocchia|Oratorio|SocietaSportiva|Scout|RnB|links|ECOComunita|news|Diari)/([a-z\-]+)/([0-9]+)\.html page.php?id=$3 [QSA,NC,NE,L] RewriteRule ^(Parrocchia|Oratorio|SocietaSportiva|Scout|RnB|links|ECOComunita|news|Diari)/([a-z\-]+)/add$ page.php?m=add&c=$2 [QSA,NC,NE,L] RewriteRule ^(Parrocchia|Oratorio|SocietaSportiva|Scout|RnB|links|ECOComunita|news|Diari)/([a-z\-]+)/([a-zA-Z0-9\-_]+)\.html page.php?al=$3 [QSA,NC,NE,L] RewriteRule ^(Parrocchia|Oratorio|SocietaSportiva|Scout|RnB|links|ECOComunita|news|Diari)/([a-z\-]+)/ list.php?c=$2 [QSA,NC,NE,L] # Level1 RewriteRule ^(Parrocchia|Oratorio|SocietaSportiva|Scout|RnB|links|ECOComunita|news|Diari)/([0-9]+)\.html page.php?id=$2 [QSA,NC,NE,L] RewriteRule ^(Parrocchia|Oratorio|SocietaSportiva|Scout|RnB|links|ECOComunita|news|Diari)/add$ page.php?m=add&c=$1 [QSA,NC,NE,L] RewriteRule ^(Parrocchia|Oratorio|SocietaSportiva|Scout|RnB|links|ECOComunita|news|Diari)/([a-zA-Z0-9\-_]+)\.html page.php?al=$2 [QSA,NC,NE,L] RewriteRule ^(Parrocchia|Oratorio|SocietaSportiva|Scout|RnB|links|ECOComunita|news|Diari)/ list.php?c=$1 [QSA,NC,NE,L] to the new rules to reflect my modifications in function.custom.php and give funcionality to my "subdomains rewrite"... Added 23 hours 47 minutes later: I was good in redirecting to http://cat1.sangelo.net with this rule: RewriteCond %{HTTP_HOST} ^(Parrocchia|Oratorio|SocietaSportiva|Scout|RnB|links|ECOComunita|news|Diari).sangelo.net [NC]
RewriteRule (.*) list.php?c=%1 [L]
but I'm not able to create second and third level of folder (e.g. htt://cat1.sangelo.net/subcat1/ and http://cat1.sangelo.net/subcat1/subsubcat1/ ) cause, using such a rule: RewriteCond %{HTTP_HOST} ^(Parrocchia|Oratorio|SocietaSportiva|Scout|RnB|links|ECOComunita|news|Diari).sangelo.net/([a-z\-]+)/ [NC]
RewriteRule (.*) list.php?c=%2 [L]
I obtain a 404 not found error, cause, as I can see from error log, that rewrite rule causes a File does not exist: /home/sangelon/public_html/subcat, referer: http://cat1.sangelo.net/ ![]() Added 20 hours 44 minutes later: Nobody can help me here... I think I must search on the web for an Apache mod_rewrite expert... This post was edited by donP (2010-03-10 13:59, 181 days ago) | |
| in BLUES I trust | |
Koradhil Posts: 413 http://www.ghengeveld.nl Location: Netherlands Rotterdam Occupation: Webdeveloper Age: 22 | #33 2010-03-10 17:06 |
RewriteCond %{HTTP_HOST} ^([A-Za-z0-9\-]+).sangelo.net$ [NC]
RewriteRule ^([a-z\-]+)$ list.php?c=$1 [NE,NC,L,QSA]
I'm pretty good with mod_rewrite, but it always requires testing and tweaking. | |
pieter Posts: 805 http://www.dutchcotonti.com Location: Belgium Tremelo Occupation: Surfing at Cotonti.com Age: 33 | #34 2010-03-11 07:22 |
| Is there some explaination on another site maybe about how these things work. ^([A-Za-z0-9\-]+ I saw it also in bbcodes, but I don't have a clue what it really means. | |
| ---------------------------------------------------------------------------------------- www.dutchcotonti.com De plaats voor nederlandse ondersteuning voor Cotonti. The place for support for Cotonti in Dutch. | |
donP Posts: 171 http://www.sangelo.net Location: Italy Rozzano (MI) Occupation: Teacher, Musician Age: 37 | #35 2010-03-11 08:18 |
# Koradhil :Your syntax doesn't take me to list.php?c=$1 but to homepage... the right syntax was mine: RewriteCond %{HTTP_HOST} !www.sangelo.net$ [NC]
RewriteCond %{HTTP_HOST} ^([A-Za-z0-9\-]+).sangelo.net$ [NC]
RewriteRule (.*) list.php?c=%1 [NE,NC,L,QSA]
But my problem was not to first level, that I personally already solved like that... The problem is for second and third level, rewriting http://cat1.sangelo.net/subcat/ redirecting to list.php?c=subcat and http://cat.sangelo.net/subcat/subsubcat redirecting to list.php?c=subsubcat 'cause a rule like the one below: RewriteCond %{HTTP_HOST} ^([A-Za-z0-9\-]+).sangelo.net/([A-Za-z0-9\-]+)$ [NC]
RewriteRule (.*) list.php?c=%2 [NE,NC,L,QSA]
still redirects to list.php?c=catPersonally I think it's a problem concerned with subdomain form in url, cause, also when rewriting http://cat.sangelo.net (that right takes me to list.php?c=cat) I have problems in displaying images, cause .tpl files address images to /skin/skinname/img/imagefile.jpg, not to the complete domain url including http://www.sangelo.net... so, also that is a real problem (I would have to correct all tpl files, hoping that we haven't too many hardcoded images that I would have to correct with core hacks)... | |
| in BLUES I trust |






