i am so tiered... somebody plz help

Using a single web hosting account to host multiple sites

i am so tiered... somebody plz help

Postby kreasta » Sat Sep 23, 2006 1:23 pm

ok... i wanna make an graphic community.

so i use 4images

i have-it on an folder - www.kreasta.be/4i (i can move-it on root if necesarry)

i want "instant subdomains" (knorr like:P)

4images makes the user gallery like this: http://www.kreasta.be/4i/member.php?act ... e&user_id=1

i know that if i`l use this htaccess:
Code: Select all
<files *>
Options MultiViews
</files>

and this script:
Code: Select all
<?
// Settings
///////////////////////////////////////////

$url = "http://www.kreasta.be/4i";
$table = "4images_users"; //do not edit if you have not changed table prefix

// Code
///////////////////////////////////////////

include "config.php";
$a_url = $_SERVER["REQUEST_URI"];
$i = explode("/", $a_url);
$b = count($i);
$b = $b-1;
$i = str_replace(array("%20"), " ", $i[$b]);
if (($i != "") and ($i != "guest"))
{
   $db = mysql_connect("$db_host", "$db_user", "$db_password") or die ("Error");
      @mysql_select_db("$db_name", $db) or die ("DB not found");
         $result = mysql_query("SELECT user_id FROM `$table` WHERE user_name='$i'");
         $row = mysql_fetch_array($result);
         $id = $row['user_id'];
      header("Location: ".$url."/member.php?action=showprofile&user_id=".$id."");
}
else
{
header("Location: ".$url."");
}
?>


i can get a redirection from www.kreasta.be/4i/who/kreasta to http://www.kreasta.be/4i/member.php?act ... &user_id=1

but how do i do it from kreasta.kreasta.be to >>>> http://www.kreasta.be/4i/member.php?act ... &user_id=1 and in the address bar to remain kreasta.kreasta.be.

sorry, i am so tiered, i am looking 4 hellp by a several weeks and nothing...

pls.. help me somehow[/code]
kreasta
 
Posts: 4
Joined: Sat Sep 23, 2006 1:12 pm

Postby richardk » Sat Sep 23, 2006 2:47 pm

To change the username to user ID (kreasta to 1), you have the following options:
  1. If you have access to the httpd.conf file you could use a RewriteMap.
  2. You could include the user ID after the username (eg kreaste-1) and ignore the username.
  3. You could edit the PHP script to query the database using the username instead of the user ID.
  4. Or you could create a PHP script the took the username, got the user ID, then include()d the main script with the new GET parameters (like the script above but not a redircet).

If i was you, i'd go for Option 4. It would be something like this: (In a file called mod_rewrite.php in the /4i directory.)
Code: Select all
<?php

// Settings
$mr['url']    = 'http://www.kreasta.be/4i';
$mr['table']  = '4images_users';
$mr['dbhost'] = 'xxx';
$mr['dbpass'] = 'xxx';
$mr['dbuser'] = 'xxx';
$mr['dbname'] = 'xxx';


// Code

$mr['username'] = explode('.', getenv('HTTP_HOST'));
if(count($mr['username']) != 3)
{
  header('Location: ' . $mr['url'] . '/', true, 301);
  exit();
}
$mr['username'] = $mr['username'][0];

if(!empty($mr['username']) && $mr['username'] != 'guest')
{
  $mr['db'] = @mysql_connect($mr['dbhost'], $mr['dbuser'], $mr['dbpass'])
        or die('MySQL Error: ' . mysql_error());
  @mysql_select_db($mr['dbname'], $mr['db'])
        or die('MySQL Error: ' . mysql_error());
  $mr['row'] = mysql_fetch_array(mysql_query('SELECT user_id FROM ' . $mr['table']
        . ' WHERE user_name="' . $mr['username'] .'"'));
  $_GET['user_id'] = $mr['row']['user_id'];
  $_GET['action']  = 'showprofile';
  unset($mr);
  include('member.php');
}
else
{
  header('Location: ' . $mr['url'] . '/', true, 301);
  exit();
}


For the subdomains you need DNS to point them to the server. Then you need them pointed to your main document root (or possibly the /4i directory) on the server. If this is not the case by default, you'll have to ask your host. Then you could use the following mod_rewrite (to work with Option 4 and the subdomains pointed to your main document root): (In a .htaccess file in your document root.)
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{HTTP_HOST} !^(www\.)?kreasta\.be$ [NC]
RewriteCond %{HTTP_HOST}  ^[^\.]+\.kreasta\.be$ [NC]
RewriteRule ^$ /4i/mod_rewrite.php [QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby kreasta » Mon Sep 25, 2006 12:39 pm

For the subdomains you need DNS to point them to the server. Then you need them pointed to your main document root (or possibly the /4i directory) on the server. If this is not the case by default, you'll have to ask your host. Then you could use the following mod_rewrite (to work with Option 4 and the subdomains pointed to your main document root): (In a .htaccess file in your document root.)

thanx veery much for the reply... but.. how do i change-it??? i use cpannel for host, and my domain is a .be

pls, rply me someone :* thx
kreasta
 
Posts: 4
Joined: Sat Sep 23, 2006 1:12 pm

Postby richardk » Mon Sep 25, 2006 2:31 pm

The document roots?
Then you need them pointed to your main document root (or possibly the /4i directory) on the server. If this is not the case by default, you'll have to ask your host.


There may be a cPanel option, but i don't know what it is.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby kreasta » Mon Sep 25, 2006 3:08 pm

ok, thx man, i`ll see tomorow, ill update a.s.a.p.
kreasta
 
Posts: 4
Joined: Sat Sep 23, 2006 1:12 pm


Return to Domain Handling

Who is online

Users browsing this forum: No registered users and 89 guests

cron