Jump to content

* * * * -

Customising URLs

IP.Board makes use of a friendly URL system. You can customise the way that these URLs are formatted.

In this example, we'll examine how to modify the IP.Blog application to be accessible from example.com/journal... instead of example.com/blog..., but you can adapt these instructions to customise any URL how you feel.
It is important to note before we proceed that the ID element of a URL (for example the topic ID when viewing a topic) is mandatory and removing it will result in problems. Furthermore, this level of customisation is not supported by IPS if any unwanted effects are caused by altering your URLs, our technicians will only advise to change them back to the default values.

IP.Board is separated into applications, and the URLs are managed for each application separately.
Application folders are in admin/applications or admin/applications_addon/* depending on the vendor and whether or not it's part of the IP.Board core.
In this article, we're using IP.Blog as an example - since IP.Blog is an addon application distributed by IPS, we'll find it under admin/applications_addon/ips/blog.
Within this folder we'll want to open the extensions/furlTemplates.php file.

This file consists of a single variable ($_SEOTEMPLATES) - each "part" represents a type of URL. In the IP.Blog file, the first entry is:
						'showentry' => array(
												'app'			=> 'blog',
												'allowRedirect'	=> 1,
												'out'			=> array( '/app=blog&module=display&section=blog&blogid=(.+?)&showentry=(.+?)(&|$)/i', 'blog/$1/entry-$2-#{__title__}/$3' ),
												'in'			=> array( 
																			'regex'		=> "#/blog/(\d+?)/entry-(\d+?)-#i",
																			'matches'	=> array( 
																									array( 'app'		, 'blog' ),
																									array( 'module'		, 'display' ),
																									array( 'section'	, 'blog' ),
																									array( 'blogid'		, '$1' ),
																									array( 'showentry'	, '$2' )
The represents the URL when viewing a blog entry.
For simply changing /blog to /journal are two parts we need to change: the second parameter in the "out" array, and the "regex" part of the "in" array.

Lets examine the "out" array:

array( '/app=blog&module=display&section=blog&blogid=(.+?)&showentry=(.+?)(&|$)/i', 'blog/$1/entry-$2-#{__title__}/$3' )

We need to change the second part there (which is in bold) if you're familiar with regex and want to modify this on a deep level, this should be viewed replacement part of a preg_replace statement.
In this article, we're just changing /blog to /journal, so we'll replace that line with:

array( '/app=blog&module=display&section=blog&blogid=(.+?)&showentry=(.+?)(&|$)/i', 'journal/$1/entry-$2-#{__title__}/$3' )

Now let's examine the regex part of the "in" array:


If you're familiar with regex, this is of course the pattern in a preg_replace statement. If you're doing advanced editing, you'll also need to modify the "matches" part of the array to map the appropriate variables.
Again, for our simple needs though, we just need to change "blog" to "journal", so we'll replace that with:


We would then go through the rest of the file and do something similar. Beware that not all sections will follow the same pattern though, for example, in IP.Blog's file you will see:
						'app=blog'		=> array( 
											'app'			=> 'blog',
											'allowRedirect' => 1,
											'out'			=> array( '/app=blog/i', 'blogs/' ),
											'in'			=> array( 
																		'regex'		=> "#/blogs#i",
																		'matches'	=> array( array( 'app', 'blog' ) )

Note that this one uses "blogs" instead of just "blog". You should take note of these differences and accommodate them (in our example, we might change this one to something like "journals") as often they are done to prevent clashes between different areas.
  • sijad, BomAle, oece and 1 other like this


thanks :)

Developer Docs · Error Codes