16

Is there a way to customize the default URLs on public-facing contribution pages or event info/registration pages to make them match the site URL schema better?

For example, a default event page URL could be something like this:

But it would be wonderful to be able to set that page to be something like this:

In some CMS setups, this would also allow better control over sidebar content that should show up only on certain contribution pages or event pages.

  • Nice feature request. Note another workaround is to use drupal rules and the redirect module to automate this. I have this on my "to do" list :) – Sonicthoughts Apr 16 '15 at 18:20
  • 1
    Some notes on exploring this in CRM-17570 - including a funky misuse of Drupal's title callback to work around CiviCRM requiring $_GET['q'] to start with civicrm :) – Chris Burgess Apr 1 '16 at 19:31
12

CiviCRM itself provides no mechanism for customizing any URL aliases, or for generating them automatically. This is handled in the CMS or at the webserver level through URL Rewrite on IIS, mod_rewrite on Apache, ModRewrite in Lighttpd, and so on.

By the book, manual aliases or redirects for contribution pages or any other CiviCRM pages are to be handled at the CMS or webserver levels.

Drupal

The recommended route is to use the Redirect module, which allows you to manually set up 3xx redirects.

The core Path module in Drupal does not support query strings, unfortunately (this is a frequently requested feature). Aliases are designed to work with internal Drupal system paths, which CiviCRM paths are not. If you want to use aliases instead of redirects, you'll need to use a workaround, some of which are suggested in the referenced thread:

Instead of using the CiviCRM-generated contributon or registration forms, you could use also Webform CiviCRM Integration to create a webform for it. Since the webform is a Drupal node, it will work with pathauto and should work with all other Drupal modules and APIs related to path aliasing.

On one of my sites, we don't display the contribution page directly, but use Drupal Views to provide a more custom layout. This neatly solves the issue because you aren't using a CiviCRM path at all, and only need to send, for instance, the event ID: https://example.net/myview/3 . Since this is a valid system path, it can not only be aliased but used in menus, and thus become https://example.net/fundraiser easily.

For example, we might set up two views: one listing upcoming events, and one to display details of an individual event. In the first view, we retrieve the event ID but hide it from display, outputting in the path to the second view. Thus, /myview/[event_id] gets populated as /myview/3. In the second view, the event_id is set up as a Contextual Filter (known in D6 as Arguments), and then we can pick and choose what fields or event information to display.

There isn't any mechanism to set up the redirects or aliases automatically. CiviCRM does not implement the Pathauto api, and exposes no Rules Events related to contribution pages or event creation to Rules.

Joomla

In Joomla, the suggested solution is to create a menu link for the contribution page and define the "pretty" URL in the alias field; naturally, Search Engine Friendly URLs must be enabled in GlobalSettings.

  • Can you explain the Views payment/registration page solution you reference in a little more detail? – Laryn - CEDC.org Mar 25 '15 at 15:51
  • 2
    @Laryn For an event registration, for example, we might set up two views: one listing upcoming events, and one to display details of an individual event. In the first view, we retrieve the event ID but hide it from display, outputting in the path to the second view. Thus, /myview/[event_id] gets populated as /myview/3. In the second view, the event_id is set up as a Contextual Filter (known in D6 as Arguments), and then we can pick and choose what fields or event information to display. – choster Mar 25 '15 at 16:01
  • @choster - nice answer - previously, I have used path aliases rather than redirects. Is there a reason you prefer redirects over aliases? Could you add that to you answer? – michaelmcandrew Mar 25 '15 at 20:54
  • @michaelmcandrew Drupal aliases are intended to handle internal system links. Since CiviCRM paths are not Drupal system links, and moreover depend on query strings which Drupal may strip off, leading to unpredictable behavior. A redirect is safer. – choster Mar 26 '15 at 22:43
  • choster: that problem with Drupal not handling the query strings has been solved. – Joe Murray Mar 27 '15 at 15:23
5

In Drupal 7, the book is a bit out of date, as URL aliases work now.

  1. Navigate to Configuration > Search and metadata > URL aliases > Add alias (this leaves you at /admin/config/search/path).
  2. Enter the CiviCRM url (without the domain part) in Existing system path, eg civicrm/contribute/transact?reset=1&id=1
  3. Enter the desired alias in Path alias, eg donate
  4. Click Save.
  • The alias doesn't seem to show up, however, if you add it to a menu. It still shows the system URL instead of the alias for some reason. – Laryn - CEDC.org May 18 '15 at 18:41
3

For WordPress there are a couple of options:

  1. Embed the form into a standard WordPress page with a shortcode. You can then use the WP URL of your choosing, in the standard WP way.
  2. Install a plugin such as Redirect Editor.
1

You would do this at the CMS level, or with Apache mod_rewrite. In Drupal, you can go to /admin/config/search/path and create a new alias to civicrm/event/info?reset=1&id=3

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.