Overview
Friendly URLs in the past had a number of limitations not the least of which was the requirement of the "/go/" prefix and the inability to easily add url attributes in addition to the friendly url string.
Friendly URLs were re-factored in FarCry 5.1
If you are using FarCry 5.0.x you should refer to the following document for Friendly URL information: Friendly URL Configuration
Implementation
We are attempting offer 2 things in FarCry 5.1
- Offer a friendly url string (that requires no prefix) that when typed after your domain name will be replaced with the relevent objectid from your application
- Provide a URL syntax that allows you define the type, objectid, template view and body view webskins
Part 1. Friendly URL String
Option A
- For Apache: mod_rewrite (free)
- For IIS: ISAPI_Rewrite 3 (or better) (not free) - This is a mod_rewrite compatible module for IIS
Place the following in your conf or .htaccess
##### APACHE MOD_REWRITE VERSION RewriteEngine On RewriteCond %{REQUEST_URI} !(^/farcry|^/webtop|^/flex2gateway|^/flashservices|^/cfide)($|/) RewriteRule ^([a-zA-Z0-9\/\-\%:\[\]\{\}\|\;\<\>\?\,\*\!\@\#\$\ \(\)\^_`~]*)$ /index.cfm?furl=$1 [L,PT,QSA]
Option B
- For IIS: Ionic's Isapi Rewrite Filter (free)
Place the following in your INI file
##### IONIC ISAPI REWRITE VERSION RewriteCond %{QUERY_STRING} ^(.*)$ RewriteCond %{REQUEST_URI} !(^/farcry|^/webtop|^/flex2gateway|^/flashservices|^/cfide)($|/) RewriteRule ^(.*)$ /index.cfm?furl=$1&%1
Sub-directory Config Example
If you are using a sub-directory installation of FarCry, here is an example of how you would set up the RewriteRule. Notice that the RewriteRule specifies the sub-directories at the start, and redirects to that sub-directory in the rewrite. These sub-directories are also included in the rewrite exception for the webtop (optional - if you want to have webtop aliases under each sub-directory rather than just from the webroot). If you have other exceptions you will need to update those as well.
##### APACHE MOD_REWRITE VERSION RewriteEngine On RewriteCond %{REQUEST_URI} !(^/farcry|^/webtop|(subdirectory1|subdirectory2)/webtop|^/flex2gateway|^/flashservices|^/cfide)($|/) RewriteRule ^/(subdirectory1|subdirectory2)([a-zA-Z0-9\/\-\%:\[\]\{\}\|\;\<\>\?\,\*\!\@\#\$\ \(\)\^_`~]*)$ /$1/index.cfm?furl=$2 [L,PT,QSA]
What Does The RewriteRule Actually Do?
The RewriteRule essentially redirects the request to index.cfm where any url (starting from the webroot) does not include a "." in it (ie, index.cfm, main.css, fotm.js) and not under the folders specified in the exception (/farcry, /webtop, /flex2gateway, /flashservices). Placing the carrot ^ before each exception (optional) specifies that the folder is directly under the webroot. You can omit the carrot in cases where folder exceptions may not lie directly under webroot.
For Example:
Browser Address |
Server Address |
---|---|
Not Redirected |
|
http::/localhost/index.cfm?furl=/my-cool-page |
|
http://localhost/my-cool-page/and-its-cool-subpage | http://localhost/index.cfm?furl=/my-cool-page/and-its-cool-subpage |
http://localhost/another-fu?page=5 |
On the page request, the farFU table is searched for the url.furl attribute. If it is found, then the url.objectid is populated with the relevent objectid just like prior to 5.1
Part 2. URL Syntax (type, objectid, view, bodyView)
As of FarCry 5.1 you can use the following url syntax as a friendly url string and if the specific friendly url string is not found in the database, it is converted to the standard url parameters most often used to access content in the system.
On the page request, the farFU table is searched for the url.furl attribute. When it is not found the url.furl attribute is parsed and turned into the following url variables:
- url.type = dmnews
- url.objectid = C98A815E-20F5-4F4E-9562C8400356C706
- url.view = displayPageStandard
- url.bodyView = displayBody
As you can see, the friendly url above is identical to typing the following in the browser http://localhost/index.cfm?type=dmNews&objectid=C98A815E-20F5-4F4E-9562C8400356C706&view=displayPageStandard&bodyView=displayBody
Of course, you dont have to have all those variables. If any are omitted, the defaults are set.
If you only pass 1 webskin name, then it is placed in the url.view attribute and the url.bodyView will be set to the default (displayBody)