As others have said, &
is a reserved character with special meaning in urls.
There are a couple options to remove or replace ampersand rather than have it be rewritten to %26
with the pathauto module. Note that these options only apply to aliases that are auto-generated, i.e. when the content has "Generate an automatic URL alias" checked.
The module's settings page (at /admin/config/search/path/settings) has options to remove punctuation or replace punctuation with the default separator. (These options are hidden in the collapsed Punctuation section near the bottom of the form.)
Additionally, pathauto provides an api hook to alter the alias yourself:
/**
* Alter Pathauto-generated aliases before saving.
*
* @param string $alias
* The automatic alias after token replacement and strings cleaned.
* @param array $context
* An associative array of additional options, with the following elements:
* - 'module': The module or entity type being aliased.
* - 'op': A string with the operation being performed on the object being
* aliased. Can be either 'insert', 'update', 'return', or 'bulkupdate'.
* - 'source': A string of the source path for the alias (e.g. 'node/1').
* This can be altered by reference.
* - 'data': An array of keyed objects to pass to token_replace().
* - 'type': The sub-type or bundle of the object being aliased.
* - 'language': A string of the language code for the alias (e.g. 'en').
* This can be altered by reference.
* - 'pattern': A string of the pattern used for aliasing the object.
*/
function hook_pathauto_alias_alter(&$alias, array &$context) { }
For example, you could use this hook to replace the &
with and
, but you must first set Ampersand to No action (do not replace) in the pathauto punctuation settings mentioned above.
/**
* Replace `&` with `and` in generated url paths.
*
* Implements hook_pathauto_alias_alter().
*/
function MYMODULE_pathauto_alias_alter(&$alias, array &$context) {
$alias = str_replace("&", "and", $alias);
}
&
is a reserved, not "special", character - you can't create a valid URL without escaping it (see RFC1738). You'll find it hard to get Drupal/pathauto to output an invalid URL, it would be considered a bug, so if you really do need to do something this unusual, you'll probably have to code it yourself