In my Staging and Production environments, Drupal is installed in subfolders of the site domain eg:

https://www.mysite.com/subfolder

In my development environment, it's not and emails are working fine; however when in Staging or Production, any url token such as [node:url], or even a hardcoded url, in the body of the email prints out incorrectly in the outputted email.

For example, if the url is supposed to be:

https://www.mysite.com/subfolder/ideas/name-of-idea

The url generated in the email is:

https://www.mysite.com/subfolder/subfolder/ideas/name-of-idea

I have written a hacky redirect to catch any url that comes in with /subfolder/subfolder/ using the arg() function, but I was hoping there was a better fix available.

Comments

brydon’s picture

Same problem here. Simplenews newsletter renders fine on the site but URLs have an extra subfolder when converted to HTML mail messages. Can you post details of your hacky redirect?

jaydee1818’s picture

I just created a module and add a function that checks the url and redirects if you get that doubling up.

So if the url that should be generated is this:

http://www.my-site.com/this/that/the-other

but it's building this:

http://www.my-site.com/this/that/that/the-other

// equal to "this"
$arg = arg(0);

// equal to "that"
$arg_1 = arg(1);

// if ok will equal "the other" if not will equal "that"
$arg_2 = arg(2); 

// if ok will be NULL if not will equal "the-other"
$arg_3 = arg(3); 

if( $arg == 'this' && $arg_1 == 'that' && $arg_2 != 'that'){
   
   // redirects to http://www.my-site.com/this/that/the-other
   drupal_goto("this/that" . $arg3); 
}
brydon’s picture

In the end I just applied the Pathologic filter. That seems to have solved the problem.

blroot’s picture

Same problem here