cotonti.com : url mod_rewrite page_add bug https://www.cotonti.com Neueste Themenbeiträge Cotonti en Thu, 09 Oct 2025 01:08:26 -0000 donP # Koradhil :
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.
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=cat

Personally 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)...]]>
Do, 11 Mär 2010 16:18:15 -0000
pieter
^([A-Za-z0-9\-]+
I saw it also in bbcodes, but I don't have a clue what it really means.]]>
Do, 11 Mär 2010 15:22:06 -0000
GHengeveld 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.]]> Do, 11 Mär 2010 01:06:45 -0000 donP
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;
}
so it returns cat.domain.net/subcat...

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...]]>
So, 07 Mär 2010 23:19:30 -0000
GHengeveld
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]]]>
So, 07 Mär 2010 05:20:43 -0000
donP

Added 20 hours 9 minutes later:

Seems to be a too complicated mission also for our good coders... :(]]>
Fr, 05 Mär 2010 01:11:19 -0000
tensh # donP : Now every word I write in url as a third level domain (e.g. http://sport.sangelo.net) gives me the home page of my website. I think this is the right way, no?

It's quite normal in some webhost configurations even without htaccess, I think.]]>
Do, 04 Mär 2010 22:56:43 -0000
donP Thank you Koradhil (ar you back to Cotonti? I'd hope this).
Now every word I write in url as a third level domain (e.g. http://sport.sangelo.net) gives me the home page of my website. I think this is the right way, no?
Now, considering I'm not a good script coder, could anyone help me to rewrite Trustmaster function.custom.php and .htaccess rules to have the first level category of page strucrture as the name of the third level domain and not the first subfolder like in the actual solution? Like this:

Instead of (actual method):

http://www.mysite.net/list.php?c=cat1 ==> http://www.mysite.net/cat1/
http://www.mysite.net/list.php?c=subcat1 ==> http://www.mysite.net/cat1/subcat1/
http://www.mysite.net/list.php?c=subsubcat1 ==> http://www.mysite.net/cat1/subcat1/subsubcat1/
...

like this:

http://www.mysite.net/list.php?c=cat1 ==> http://cat1.mysite.net
http://www.mysite.net/list.php?c=subcat1 ==> http://cat1.mysite.net/subcat1/
http://www.mysite.net/list.php?c=subsubcat1 ==> http://cat1.mysite.net/subcat1/subsubcat1/
...


Is it possible?]]>
Do, 04 Mär 2010 18:40:22 -0000
GHengeveld Do, 04 Mär 2010 17:17:01 -0000 Trustmaster Mi, 03 Mär 2010 01:48:22 -0000 donP http://sangelo.net to http://www.sangelo.net
Is it a good sign in that sense?]]>
Mi, 03 Mär 2010 01:15:45 -0000
Trustmaster Mi, 03 Mär 2010 00:45:00 -0000 donP what have I to do to configure my domainzone to make working those "fake" subdomains?
Have I to contact my hosting Provider or is it a trick I can personally do (by cPanel or htacces)?]]>
Di, 02 Mär 2010 22:43:16 -0000
Trustmaster Di, 02 Mär 2010 22:25:37 -0000 donP http://www.cotonti.com/forums.php?m=posts&q=2509 ) but unfortunately, when I rewrite
http://www.sangelo.net/list.php?c=category1
with
http://category1.sangelo.net
my Server redirects me to a courtesy page :( What's the problem? :/

Added 16 minutes later:


In the end, I would have a new method deriverd from your one (to create fake subdomains taking domaniname from the fisrt category of categories structure)...

Instead of (your actual method):

http://www.mysite.net/list.php?c=cat1 ==> http://www.mysite.net/cat1/
http://www.mysite.net/list.php?c=subcat1 ==> http://www.mysite.net/cat1/subcat1/
http://www.mysite.net/list.php?c=subsubcat1 ==> http://www.mysite.net/cat1/subcat1/subsubcat1/
...

like this:

http://www.mysite.net/list.php?c=cat1 ==> http://cat1.mysite.net
http://www.mysite.net/list.php?c=subcat1 ==> http://cat1.mysite.net/subcat1/
http://www.mysite.net/list.php?c=subsubcat1 ==> http://cat1.mysite.net/subcat1/subsubcat1/

Is it possible?
]]>
Di, 02 Mär 2010 21:38:51 -0000
Trustmaster Di, 02 Mär 2010 16:38:06 -0000 donP

What about if I would have a different rule for one category, like this:

list.php?c=Category1 ==> http://Category1.mydomain.net
list.php?c=subcategory1 ==> http://Category1.mydomain.net/subcategory1
list.php?c=subsubcategory1 ==> http://Category1.mydomain.net/subcategory1/subsubcategory1

But only for some categories (living the other rules like now, with the intent of creating a fake subdomain for one or two categories of my website).

Added 1 day later:

Nobody here? :(]]>
Mo, 01 Mär 2010 03:35:49 -0000
Trustmaster
Added 17 minutes later:

I see the problem about your plugin now. It uses $out['uri']:
$area_location = substr($out['uri'], 0, strpos($out['uri'], '.'));
Which is incorrect, because $out['uri'] depends on exact way of URL output.
The more correct way to get current area is:
global $z;
$area_location = $z;
]]>
Fr, 12 Feb 2010 04:09:31 -0000
donP Tefra GenSiteMap)...]]> Mi, 10 Feb 2010 20:51:55 -0000 pieter Menuslots are not generated automatically.]]> Mi, 10 Feb 2010 02:27:23 -0000 donP docs rewrite part)

2) Now it's clear

3) I changed with RewrtiteBase

4) This is a real problem, cause webBots are ravenous with links in pages, and we would think about a parsing solution to use url_rewriting method also in pages and menu slots

5) So, we wouldn't use user part of the script, for now...

6) I really can't understand, but, unfortunately I can't test in local cause (I don't know the reason) my wampserver goes crazy if I try to use url_rewriting...

So, if you had time to look at the code, this is my plugin:
]]>
Mi, 10 Feb 2010 01:46:24 -0000
Trustmaster fixed version

2) Because in docs here category code is split by dashes: docs-en-user becomes docs/en/user. In other categories (e.g. downloads) subcategories have simple codes like plugins.

3) Sorry. How did you change it?

4) You're right, it does not rewrite static text. Static text should use new links.

5) Yes, it has bugs so it is not recommended to use.

6) Can I test your plugin to see the reason?]]>
Di, 09 Feb 2010 17:13:43 -0000
donP
1) functions.custom.php uses eregi() that is deprecated from PHP 5.3.0

2) I don't understand why docs have different rewriting rules :/

3) I had to change RewriteRuleBase at the beginning of .htaccess cause it generated a 500 internal Server Error

4) url_rewrite doesn't rewrite links in menu slots and links in pages (parsed text)

5) users rewriting causes me many problems

6) list.php?c= rewriting is transparent to my headerchanger plugin, instead page.php?id= and page.php?al= not at all...]]>
Di, 09 Feb 2010 16:29:11 -0000
Trustmaster an example of current files used on this site. Add problem is fixed there, except for problems with Wiki plugin.]]> Di, 09 Feb 2010 01:54:50 -0000 donP Mo, 08 Feb 2010 22:14:56 -0000 Trustmaster Fr, 29 Jan 2010 00:43:31 -0000 donP page.php?m=add&a=add...
The problem is that, nomral users pages go to validation queue and redirection points to index.php; Admins pages - instead - go to database directly and redirection points immediatly to page.php?id=#(the new inserted page ID). This is bad interpreted by url_rewrite engine I think, so a "930 bad url message" has returned.]]>
Do, 28 Jan 2010 23:47:14 -0000
Trustmaster Do, 28 Jan 2010 22:11:00 -0000 donP ]]> Do, 28 Jan 2010 21:44:01 -0000 Trustmaster Do, 28 Jan 2010 21:24:31 -0000 donP # Gökhan YILDIZ :
RewriteRule ^(articles|news|videos|bla|bla2|bla3)/([a-z-]+)/add$ page.php?m=add

Nothing to do with this and nothing also with Trustmaster one...

The only way I find was putting
page	id=*	{page_url_structure()}
page	al=*	{page_url_structure()}    /*because page	al=*|id=*	{page_url_structure()} doesn't work  :/ */

in datas/ultrans.dat instead of
page	*	{page_url_structure()}

so the page.php?m=add&c=... hasn't rewritten anymore, BUT... there still a problem: in this way the page has successfully added to the database, but a user with category-related admin rights receives a 930 redirect error message saying the operation isn't allowed... this error doesn't happen when a level 1 users inserts a new page (and that page goes to validation queue)...

what's the matter? :/

Added 8 days later:

Noone here to answer this? :(]]>
Mi, 20 Jan 2010 09:40:22 -0000
Gökhan YILDIZ RewriteRule ^(articles|news|videos|bla|bla2|bla3)/([a-z-]+)/add$ page.php?m=add]]> Mi, 20 Jan 2010 05:51:24 -0000 donP 100 RewriteConditions?! :O
Isn't there a way to modify {page_url_structure()} function so it can to handle the m=add parameter outputting a right url?]]>
Mi, 20 Jan 2010 02:23:23 -0000
Trustmaster
foo/([a-z-]+)/([a-z-]+)/add$ page.php?m=add&c=foo-$1-$2
foo/([a-z-]+)/add$ page.php?m=add&c=foo-$1
bar/([a-z-]+)/([a-z-]+)/([a-z-]+/add$ page.php?m=add&c=bar-$1-$2-$3
bar/([a-z-]+)/([a-z-]+)/add$ page.php?m=add&c=bar-$1-$2
bar/([a-z-]+)/add$ page.php?m=add&c=bar-$1
]]>
Di, 19 Jan 2010 21:36:11 -0000
donP Kilandor detailed Guide many users comments remark the bug with page_add...

Kilandor answer like this:

Kilandor:
Modify .htaccess rules so that it looks for /add at the end of the URL, for example:
docs/([a-z-]+)/([a-z-]+)/add$ page.php?m=add&c=docs-$1-$2

But I ask:
But... have I to write such a similiar line for every category and subcatecory of my site?!?! :O

Any explainations? :(
Thank you]]>
Di, 19 Jan 2010 19:13:46 -0000