Arrow Home arrow Forums
larger font smaller font default font Fixed screen resolution Auto adjust screen size

Joomlapolis Forums  


<< Start < Prev 1 2 3 4 5 6 7 8 9 10 Next > End >>
Howto: create homepages and 'subdomains' per user
Date: 2006/06/16 02:04 By: trail Status: User  
Karma: 719  
Gold Joomlapolitan

Posts: 474
graphgraph
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:
Code:

 RewriteEngine On



Step 2) establish the rewriting base and default directory index

Code:

 DirectoryIndex index.php RewriteBase /



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

Code:

 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'

Code:

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



Step 4) Actually rewrite the request.
Code:

 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 http://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:

Code:

 RewriteCond %{HTTP_HOST} ([^/]+)\.domain\.com [NC] RewriteCond %!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 http://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_comprofiler&task=userProfile&user='username'

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

Happy rewriting!
~Trail.

This post in a file:
File Attachment:
File name: howto.txt
File size:2541 bytes


Post edited by: trail, at: 2007/03/13 04:32
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
Click here to see the profile of this user The administrator has disabled public write access.

Re:Howto: create homepages and 'subdomains' per us
Date: 2006/06/17 16:10 By: Jelte Status: User  
Karma: 3  
Junior Joomlapolitan

Posts: 29
graphgraph
Unfortunately this ain't working anymore if your using a SEF component (like OpenSEF).
Click here to see the profile of this user The administrator has disabled public write access.

Re:Howto: create homepages and 'subdomains' per us
Date: 2006/06/18 01:44 By: trail Status: User  
Karma: 719  
Gold Joomlapolitan

Posts: 474
graphgraph
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
Click here to see the profile of this user The administrator has disabled public write access.

Re:Howto: create homepages and 'subdomains' per us
Date: 2006/06/18 09:50 By: ericfoster3 Status: User  
Karma: 144  
Senior Joomlapolitan

Posts: 84
graphgraph
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
Click here to see the profile of this user The administrator has disabled public write access.

Re:Howto: create homepages and 'subdomains' per us
Date: 2006/06/19 05:52 By: micoots Status: User  
Karma: 0  
Senior Joomlapolitan

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

trail wrote:

File Attachment:
File name: howto.txt
File size:2541 bytes


Good luck<br><br>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.
Click here to see the profile of this user The administrator has disabled public write access.

Re:Howto: create homepages and 'subdomains' per us
Date: 2006/06/19 05:55 By: micoots Status: User  
Karma: 0  
Senior Joomlapolitan

Posts: 58
graphgraph
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.
Click here to see the profile of this user The administrator has disabled public write access.

<< Start < Prev 1 2 3 4 5 6 7 8 9 10 Next > End >>

CBSubs 1.0

CBSubs 1.0.3 released!

Find out more about the revolutionary new Joomla subscription system:

Info on CBSubs

CB 1.2.3 Documentation

Thank you bonus:

ProfileBook (+Blog) 1.2RC
ProfileGallery 1.2RC2
CB Privacy 1.0RC

What? Why? Where?

Click here for a yearly subscription: subscribe now

CB 1.2.3 Download

Community Builder 1.2.3
Stable and native for:
Joomla 1.5 & 1.0 & Mambo
(incl. CB 1.2.3 Installation pdf)
You need to be a registered member to download.

Full 180 pages updated
CB 1.2.3 documentation:
You need to be a CB doc subscriber to download.

CB Login