17

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.

2
  • 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 :) Commented Apr 16, 2015 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 :) Commented Apr 1, 2016 at 19:31

6 Answers 6

14

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.

6
  • Can you explain the Views payment/registration page solution you reference in a little more detail?
    – Laryn
    Commented Mar 25, 2015 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
    Commented Mar 25, 2015 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? Commented Mar 25, 2015 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
    Commented Mar 26, 2015 at 22:43
  • choster: that problem with Drupal not handling the query strings has been solved.
    – Joe Murray
    Commented Mar 27, 2015 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.
1
  • 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
    Commented May 18, 2015 at 18:41
4

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
  • Update: don't use Redirect Editor - it was taken over and went weird Commented Aug 26, 2020 at 10:38
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

1

It takes some manual work, but for some important Civi links and events etc., I've just been putting them in my .htaccess file in root of my linux/Apache setup. Here's an example.

Redirect 301 /contribute https://watershedmg.org/civicrm/contribute/transact?reset=1&id=5
Redirect 301 /Contribute https://watershedmg.org/civicrm/contribute/transact?reset=1&id=5
Redirect 301 /happyrain https://watershedmg.org/civicrm/event/info?reset=1&id=533
0

Backdrop

Backdrop has many of the same potential solutions as described Drupal 7, but also a few that are unique to Backdrop:

  • CiviCRM Fields: Insert CiviCRM Contribution pages or Event Registration pages into fields which are attached to entities as usual (Nodes, Terms, Users)
  • CiviCRM Blocks: Same as above but insert via blocks in a layout instead of an individual field. (Great for inserting on multiple pages at once, for example in an entire section of the website).
  • Layout conditions that consider query parameters: This one is a feature request with a functional PR, but will allow you to specify visibility conditions based on query parameters, which gets to the original question of how to control sidebar or other content on the page based on which CiviCRM page is being viewed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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