Cotonti / Open Source PHP Content Management FrameworkContent Management Framework

Forums / Cotonti / Support / [problem] Page lists as subdomains

#1 2013-02-04 14:46


A quick question: what should I do to rewrite page lists to subdomains? (and will it consider internationalization plugin?)

like: into

Thanks in advance,

(I'm not good at searching forums for answers, I was searching like an hour for this topic ^^)


side question:
Do you consider forum rewrite in the future? Forum rewrite is awesome because of the amount of info that would be indexed by google. If not, would it be possible to do by myself as a plugin?

Added 23 hours later:

Okay, I have some progress... but still questions.

I made this in urleditor plugin:

page     *                   http://{$c}.{$_host}/{$al}
page     c=*               http://{$c}.{$_host}/
page     c=*&al=*     http://{$c}.{$_host}/{$al}

Do I have to add here anything else?

How can I make the second nested page category be displayed like '' ??

Also, how can I stay logged in when browsing subdomains? I can't switch Cotonti to multidomain since it breaks the rewrite rules.

Added 3 minutes later:

P.S. My htaccess:

# All the rest goes through standard rewrite gateway
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^?]+) index.php?rwr=$1 [QSA,NC,NE,L]
RewriteCond %{HTTP_HOST} ^([^/&?#]+)\.localhost$ [NC]
RewriteRule ^(.*)$ page.php?c=%1$1 [QSA,NC,NE,L]
RewriteRule ^([^/&?#]+)(.*)$ page.php?c=%1&al=$1$2 [QSA,NC,NE,L]

This post was edited by tensh (2013-02-05 14:11, 5 years ago)
#2 2013-02-05 15:27

It's not a quick question at all, finetuning URLs for subdomains is not so easy to do.

In order to break the category path into a subdomain and a part after slash, you'll have to write your own functions to be used in rewrite rules, e.g. {my_page_url()}.

The forums rewrite is possible in a similar way. I can share some code with you if you're interested. It's not there by default because it uses lots of extra queries and affects performance. We need to scratch all forum URLs completely and change quite some code in order to have nice forums URLs by default.

You need $cfg['multihost'] = true for auth to work on subdomains and also check the cookiedomain setting, for multidomain sites it is usually set to something like "". Regarding your .htaccess, keep in mind that rules are applied top to bottom, so if the top rule hits, it won't even look for your bottom rule.

May the Source be with you!
#3 2013-02-06 08:41

Of course, I would be glad to see some of your code! I'm very interested!

#4 2013-02-06 10:37

i'm interesting also!

how it happened that I forgot about setting 'multihost' option =((

#5 2013-02-07 08:17

Here is an example functions.custom.php for forums rewrite function.

May the Source be with you!
#6 2013-02-07 18:33

thank you.

I'll play with that later...

#7 2013-02-08 07:18

Great! Thank you :) But how would then the htaccess look like? and urltrans.dat? :)

Also, as for my problem, I saw on Github discussions a solution with multifolder separate installs, but sharing the same database and session (if I understood it correctly) - is it possible?

With all these rewrites, my website will look so professional :)

#8 2013-02-08 10:45

If you need subdomains just for site categories, it's not worth installing multiple instances then. We just need to sit down and work out a subdomains solution. I've been lacking time for that so far...

May the Source be with you!
#9 2013-02-11 07:37

Yeah, and at least one subdomain must have the multilanguage support :/

Anyway, I'm still interested in multiple instances for my other project - an old site currently on Genoa which I want to port to Siena. It's very big, very old (10 years old), and I think multiple instances might be a good idea.

Added 5 hours later:

By the way, today I discovered something. It might be a slight bug.

Let's assume I have the following structure:

1. products
1.1 technical-data
2. products-green

... and I add a page with alias "technical-data" under "products-green" and have nice-urls set with rewrites, ... and it redirects me to a category list 1.1 technical-data, not to a page "technical-data" under a different category!

Strange, isn't it? Do you get the same behaviour?

Added 2 days later:

Can you help me with maintaining current login session through subdomains? When I set "multidomain" to true, the rewirte rules somehow break... (urls are strange)

Added 5 days later:

I also have problem with page add :( :( in admin panel there's only m=add parameter...

The redirection rules aren't too intuitive. 

This post was edited by tensh (2013-02-18 09:33, 5 years ago)