Prev |  | Next

### 2.3.6. Building URLs for Phorum

#### 2.3.6.1. Introduction

You might have noticed that all URLs that are used by Phorum are full absolute URLs. Phorum does not use relative URLs anywhere. and all of the URLs that point to Phorum PHP scripts are generated by the function `phorum_get_url()`. This was done for several reasons. Here are some of them, for the curious developer:

- By generating full URLs, we guarantee ourselves that the user is always opening pages within the same domain. With relative URLs, the user might end up at a different domain because of some webserver redirect (e.g. from `http://example.com` to `http://www.example.com`), causing possible loss of cookies as a result (since cookies bind to domains). Loss of cookies result in the user being logged out.
- Integrating Phorum in a website is a lot easier when using absolute URLs. When editing the header template for example, it should be okay to add a `<base href="..."/>` in there, pointing at the URL where the original site exists. After doing so, the header template can use the same constructions and paths as the main site's header template.
- This becomes even more important when running Phorum in portable or embedded setups. There, Phorum will be run from some script at a random location and no longer from a script in the Phorum directory. By using absolute URLs, the linked resources can still be found.
- Code for generating absolute URLs is needed for generating URLs that can be put in mail messages. It's a logical choice to use the same code for generating the other URLs in Phorum, so only one URL generating function has to be maintained.
- By letting `phorum_get_url()` generate all URLs, we are prepared for future changes and new features. If changes are needed in the URL schema, we only have to update this function and nothing further. All core code and modules that use this function will automatically follow the changes.

Prev | Up | Next
| Home |