Issue creating “custom” user URLs

lkjfds

New Member
I am running into the following issue:Our members have a desire for personalized sites directly from our primary domain in the form of \[code\]http://www.example.com/membername\[/code\]. I am looking at possibly solutions in two ways but neither are ideal (will be explained below). Method 1 - \[code\]?Member=\[/code\]In this method, I simply create a custom URL and store the information in the member's database profile. For example: if I want my "custom" URL to be jm4, for a consumer to visit my site, they must type in \[code\]http://www.example.com?Member=jm4\[/code\].The site, of course, does a \[code\]$_GET['Member']\[/code\] to lookup the member information, stores the primary data in Session from the index page, then redirects to a homepage. The consumer no longer sees the membername in the URL but instead sees all the page names for www.example.com as if they simply visited the parent domain to start (each member's page has custom information however).While this method works it presents the following problems:
  • The URL is not nearly as easy as \[code\]/jm4\[/code\]and any errors typing out thewildcard \[code\]?Members=\[/code\] will result inpage error. Also, This method keepsthat particular member's informationin session (which is necessarybrowing from page to page on thatparticular member domain) andprevents somebody from simply typing\[code\]http://www.example.com?Member=name2\[/code\] tovisit another site without clearingtheir session or closing the browser.
Method 2 - \[code\]/membername\[/code\]While the preferred method, currently the only way we know how to create is to manually generate an index file in a subfolder, redirect to the primary index then allow the consumer to view the member's personal site.For example, if I visit \[code\]www.example.com/jm4\[/code\], I am hitting the \[code\]/jm4\[/code\] folder which contains index.php. Within this file simply contains:\[code\]<?phpsession_start();ob_start();$_SESSION['AgentNumber'] = "779562";header("Location: ../index.php");exit;?>\[/code\]the primary index recognizes this with:\[code\]<?phpsession_start();ob_start();if ($_SESSION['MemberNumber'] == NULL) { header("Location:ac/"); exit;}$conn = mysql_connect("localhost", "USER", "PW");mysql_select_db("DB",$conn);$sql = "SELECT * FROM table WHERE MemberNumber = $_SESSION[MemberNumber]";$result = mysql_query($sql, $conn) or die(mysql_error());while ($newArray = mysql_fetch_array($result)) { $_SESSION['MemberName'] = $newArray['MemberName']; $_SESSION['MemberPhone'] = $newArray['MemberPhone']; $_SESSION['MemberMobile'] = $newArray['MemberMobile']; $_SESSION['MemberFax'] = $newArray['MemberFax']; $_SESSION['MemberEmail'] = $newArray['MemberEmail']; $_SESSION['MemberAddress'] = $newArray['MemberAddress']; $_SESSION['MemberCity'] = $newArray['MemberCity']; $_SESSION['MemberState'] = $newArray['MemberState']; $_SESSION['MemberZip'] = $newArray['MemberZip']; $_SESSION['MemberAltName'] = $newArray['MemberAltName'];}mysql_close($conn);header("Location: home/");exit;?>\[/code\]We would certainly prefer to use the second method in terms of 'ease' for the member but keep running into the following issues:[*]We are forced to manually create asub-folder and unique index.php filefor each new member we onboard[*]While the above probably could beautomated (when new member createsprofile, automatically generate phpfile and folder) but this is morecomplicated and we don't want tohave 3000 subfolders on the primarydomain.Has anybody run into similar issues? If so, how did you go about solving it? What would you recommend based on my details above? Any advice is appreciated.Also - using as subdomain (\[code\]membername.example.com\[/code\]) is not preferred because our current SSL does not allow for wildcards.EDIT 1 - EXISTING .HTACCESS FILEMy existing .htaccess file on the site looks like this for reference:\[code\]ErrorDocument 404 /404.phpRewriteEngine onRewriteCond %{REQUEST_FILENAME} !-dRewriteCond %{REQUEST_FILENAME}\.php -fRewriteRule ^(.*)$ $1.php [L]RewriteRule ^(.*)$ /?Member=$1 [L]\[/code\]
 
Back
Top