| 
Welcome, Guest

Howto: create homepages and 'subdomains' per user
(1 viewing) (1) Guest

TOPIC: Howto: create homepages and 'subdomains' per user

Howto: create homepages and 'subdomains' per user 5 years, 7 months ago #15382

  • Posts:
  • Karma:
Some webmasters requested that i write up a complete tutorial on creating user home pages and virtual subdomains for your members profiles. Here you go:

Requirement: ModRewrite installed on the webserver, ask your host.

First the easy part, creating userhomepages like www.domain.com/username

Edit the .htaccess file in the root of your webserver

Step 1) turn the rewrite engine on:
RewriteEngine On


Step 2) establish the rewriting base and default directory index

DirectoryIndex index.php
RewriteBase /


if you have your website in a subdir on your webserver you need to reflect that like so:

DirectoryIndex index.php
RewriteBase /subdir/


Step 3) Create the conditions for when to rewrite userhomepages:
The following lines say 'if the request is not a directory nor a real file, continue to rewrite it'

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d


Step 4) Actually rewrite the request.
RewriteRule ^([^/]+)/?$ index.php?option=com_comprofiler&task=userProfile&user='$1' [L]


You are now done creating userhomepages. Lets continue creating virtual subdomains for your users.

Requirement: DNS settings.

You first have to prepare your DNS server to allow all requests for any subdomain to go to your original website. So that means you need to see your website if you type in a rubbish subdomain like asdfasdf.domain.com
Not everyone is knowledgable in DNS but this is where your hosting provider comes in. Ask them to do this for you.

Step 5) Translate username.domain.com to www.domain.com/username

Below Rewritebase and above the rewritecondition add:

RewriteCond %{HTTP_HOST} ([^/]+)\.domain\.com [NC]
RewriteCond %1 !www$ [NC]
RewriteRule ^(.*)$ http://www.domain.com/%1 [L]


This translates username.domain.com to www.domain.com/username and does not show username.domain.com in the adress bar, as much as we would like that, it is currently not possible because joomla also uses the subdomain part to generate the login cookie. Entering the site with a different subdomain (not www but username) invalidates the cookie and thus the login.

Now when a request comes in for username.domain.com the rewrite engine first translates it to www.domain.com/username and then rewrites that to www.domain.com/index.php?option=com_comp...serProfile&user='username'

Here you can see it in action: tester.djtrail.nl

Happy rewriting!
~Trail.

This post in a file:

Attachment howto.txt not found



Post edited by: trail, at: 2007/03/13 04:32
Attachments:
DJ Trail.
CB Co-Founder & Test-Lead.
Plugins: My Age, Starsign Matchmaking Horoscope, My Visitor, My Highscores, My ProfileID,
My Components: Import & Invite Karma Casino (Use Test / Test)
My Modules: Many

Re:Howto: create homepages and 'subdomains' per us 5 years, 7 months ago #15474

  • Posts:
  • Karma:
Unfortunately this ain't working anymore if your using a SEF component (like OpenSEF).

Re:Howto: create homepages and 'subdomains' per us 5 years, 7 months ago #15489

  • Posts:
  • Karma:
yes im fighting on ever joomla update to keep this working..

current 109 sef breaks it a bit too.. most works except the redirect after writing a guestbook message.. just replace old 108 sef..

but its worth to fight for it i think..

Post edited by: trail, at: 2006/06/17 19:45
DJ Trail.
CB Co-Founder & Test-Lead.
Plugins: My Age, Starsign Matchmaking Horoscope, My Visitor, My Highscores, My ProfileID,
My Components: Import & Invite Karma Casino (Use Test / Test)
My Modules: Many

Re:Howto: create homepages and 'subdomains' per us 5 years, 7 months ago #15505

  • Posts:
  • Karma:
What a neat trick! Thanks for the tip.
CB 3rd Party Developer: DatsoTab | KarmaTab
Joomla! 1.0.10
Community Builder 1.0
joomlaboard 1.1.2

Re:Howto: create homepages and 'subdomains' per us 5 years, 7 months ago #15548

  • Posts:
  • Karma:
Hi Trail (and anyone else that knows the answer to this),

trail wrote:

Attachment howto.txt not found



Good luck:)

Post edited by: trail, at: 2006/06/15 20:31


This is a nice piece of work, thank you.

I noticed one thing though, registered users (people logged in) can see and type in the url's no problem, but anonymous web users get the "you need to login" message.

How can I make the profile publicly viewable?

Thanks.

Michael.

Re:Howto: create homepages and 'subdomains' per us 5 years, 7 months ago #15549

  • Posts:
  • Karma:
micoots wrote:
I noticed one thing though, registered users (people logged in) can see and type in the url's no problem, but anonymous web users get the "you need to login" message.

How can I make the profile publicly viewable?

Thanks.

Michael.


I spoke too soon. I found the view option in the CB User Profile section, all done and working now

Michael.
Time to create page: 1.38 seconds