|
|
Howto: create homepages and 'subdomains' per user
|
|
Date: 2006/06/16 02:04
|
By: trail
|
Status: User
|
|
|
Karma: 719  
|
|
Gold Joomlapolitan  | Posts: 474 |   | |
|
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:
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 %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 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.txtFile 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 
|
|
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 |   | |
|
|
Unfortunately this ain't working anymore if your using a SEF component (like OpenSEF).
|
|
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 |   | |
|
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 
|
|
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 |   | |
|
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
|
|
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 |   | |
|
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.
|
|
The administrator has disabled public write access. |
|
|