User Friendlier URLs in SugarCRM

sugarcrmdevelopers —  November 17, 2010 — 3 Comments

A few weeks back I filed an IT Request to have an easier way to file IT Requests. Essentially, I just wanted to type ITR in my browser and have it take me to the create IT Request view we have in our Sugar Instance. The IT folks fired back with a bug to have user friendly URLs in the application. I decided to take them up on the challenge and after a few minutes of hacking we had a working prototype.

Here are the different types of URLs we were looking to generate













The nice thing about this is that you can include details such as the name through within the URL so when you are sending links around they can have information




/msi/Contacts/search/Sal – would search for Sal in Contacts

and here is how it was done.

Changes to .htaccess file changes

RewriteRule ^msi/([^/]+)/edit/([^/]+) index.php?module=$1&action=EditView&record=$2
RewriteRule ^msi/([^/]+)/(new|edit)$ index.php?module=$1&action=EditView
RewriteRule ^msi/([^/]+)/view/([^/]+) index.php?module=$1&action=DetailView&record=$2
RewriteRule ^msi/([^/]+)/search/([^/]+)$ index.php?module=$1&action=index&name_basic=$2&search_name_basic=$2&query=true&searchFormTab=basic_search
RewriteRule ^msi/([^/]+)/(edit|new|search|view)/(.*)  $3
RewriteRule ^msi/([^/]+)/(.*) $2

Changes to the application

edit themes/Sugar/tpls/_head.tpl  (not upgrade safe)



<base href='http://'>

This tells the application that no matter what the URL is in the address bar base all files (css, images, js) off of this base URL

Then create the following file in custom/include/MVC/View/views/view.detail.php

header("Location: /msi/{$this->module}/view/{$this->bean->id}/{$summary}");


In a future post hopefully we will be able to dive into making even friendlier URLs

/msi/Cases/view/<case number>

as well as RESTifying our REST API.

Let me know what you think or if you have any suggestions on making this better – this was just a quick prototype (less than 30 min) we threw together, and wanted to get as much working without changing the core code base.

3 responses to User Friendlier URLs in SugarCRM


    The ugly long URLs that SugarCRM creates has always caused me to wrinkle my nose at them whenever I have to send someone a link.
    This will certainly make that much easier. I probably won’t even need to explain what the link goes to as it’ll be self evident in the URL.


    Do you have Nginx config for same?
    Also, is it simplified with SugarCRM v6.4?

Trackbacks and Pingbacks:

  1. How to rewrite URL with "apache Conf" or ".htaccess file"? - January 21, 2013

    […] […]

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s