views:

48

answers:

3

I intend to give my users the ability to share a link to their profile with other people, however this link should not be the usual link. Instead :

  • it should not give out the real landing page
  • the user should be able to deactivate it if they wish

Is this possible ?

+4  A: 

The page could be

PublicUserProfile.php?UserViewId=12345

Behind the scenes (in the db or something), 12345 is mapped to user SantaClaus.

If SantaClaus decides, he no longer wants his profile publicly available, then delete the mapping of 12345=SantaClaus.

Jay Allard
+1  A: 

Depends on if it redirects to the actual resource.

They should never be allowed to give out the "actual resource", only aliases that point to that resource.

Then you can turn the alias on or off.

But if you give out the actual resource or do a browser redirect to the unique resource, you can't do it.

Answer: only issue aliases

Homer6
+1  A: 

You may want to have a DB with the fields "ID" and "URL", where ID is some autoincrement value, and URL the URL you want to redirect to.

The you build yourself a redirect script (e.g. called redirect.php):

<?php
  // some configuration
  if (!empty($_SERVER['PATH_INFO'])) {
    $_GET['id'] = substr($_SERVER['PATH_INFO'],1);
  }
  if(!empty($_GET['id'])) {
    // You have to build a function which returns the URL from DB for this ID
    // Remember: You new complete URLs for redirects
    $url = get_url_for_this_id($_GET['id']); 
    if (!empty($url)) {
      header('Location: '.$url);
      exit;
    }
  }
  echo('No URL found');
?>

And the user calls your script like:

redirect.php/1234 or redirect.php?id=1234

fboes