Add a prefix to all path with hook_url_outbound_alter and/or hook_url_inbound_alter I'm trying to add a prefix to all path aliases, without changing the URL's destinations (internal path) of my website.

I'm setting a $_SESSION var with hook_init() when a visitor arrive on the website. This $_SESSION var is determined by the incoming URL of the visitor.

The website is should be accessible by different URL like:


http://www.mydomain.com/ (default)
http://www.mydomain.com/thisevent
http://www.mydomain.com/whatevent ...


So if the $_SESSION var is "thisevent", I'd like to change all default path like this: 


http://www.mydomain.com/some-page into
http://www.mydomain.com/thisevent/some-page
http://www.mydomain.com/another-page into
http://www.mydomain.com/thisevent/another-page ...


I think this could be done with hook_url_outbound_alter() and/or hook_url_inbound_alter() but I can find any clear examples to implement my goal. 
I found this post but the author didn't post his solution.

Any help appreciate.
Thanks
I finally made it but not without the help of a sympathetic module: PURL.

And here's my final solution:


Create a custom module
In the mymodule.module file create 3 functions:

/**
 * Implements hook_purl_provider
 */
function mymodule_purl_provider() {
  return array(
    'mymodule_provider' =&gt; array(
      'name' =&gt; t('My module provider'),
      'description' =&gt; t('Sets a prefix for URL.'),
      'callback' =&gt; '_mymodule_prefix',//I didn't really use this callback and I don't really know how to :-)
      'example' =&gt; 'my-prefix',//anything you want. only for UI I think
    ),
  );
}

function mymodule_purl_modifiers() {

  $mymodule_events = _get_all_events();//custom function to get some data

  foreach ($mymodule_events as $kid =&gt; $e) {
    $modtab['mymodule_provider'][] = array('value' =&gt; $e['alias'], 'id' =&gt; $e['nid']);//this array must be structured like this!
  }
  return $modtab;
}


function _mymodule_prefix(){
  $event = _get_one_event();//custom function

  if ($event) return true;
}



then you can go in /admin/config/search/purl to configure PURL with your data you've just created with mymodule.


In /admin/config/search/purl/types you select the type you need (I checked only "Path")
In /admin/config/search/purl/list you should see your modifiers you've created with mymodule.
And in /admin/config/search/purl you can select witch type you use for your provider


I am a bit sad because I didn't manage to use the 2 hooks (like purl does :-) but the good news is that "it works"

Cheers.