Keeping plus and other chars in Drupal url encoding

Drupal CMS TipsRecently, I was working around keeping “+” in my Drupal page URLs. By default it replaces all pluses to “%2B”. I even used “Pathauto” module, but it didn’t help too.

So what’s the solution?

I went trough two Drupal files and edit/add one row in each file.

1) Open includes/common.inc

Find (around line 640):

return str_replace('%2F', '/', rawurlencode($path));

Change to:

return str_replace(array('%2F', '%2B'), array('/', '+'), rawurlencode($path));

1) Open includes/bootstrap.inc

Find (around line 2804):

$request_path = strtok($_SERVER['REQUEST_URI'], '?');

And add AFTER:

$request_path = str_replace('+', '%2B', $request_path);

So the end result would be:

$request_path = strtok($_SERVER['REQUEST_URI'], '?');
$request_path = str_replace('+', '%2B', $request_path);

==============

So that’s it 😉 Have fun!

 

 

Leave a comment