I am building a simple form to redirect users to a shopping cart, including their form choices in the URL.

The tokenized redirect URL looks perfect, except for the fact that Drupal thinks it must be an internal URL and strips off the http://www.domain.com portion of the URL, leaving me with a page not found error.

I've turned on debugging and everything works as expected... except for the destination URL.

I have searched and searched and can't find a reference for this issue... is there something somewhere I need to set to make rules redirect to an external URL?

Thanks for any help!

Comments

klausi’s picture

Component: Rules Core » Rules Engine
Status: Active » Postponed (maintainer needs more info)

works fine for me. are sure to use a full url like "http://example.com" and not only "example.com"?

webwriter’s picture

Yes, using a full URL, as stated in the original post. It just ignores everything before the first / and tries to find a local URL.

hampshire’s picture

I have the same problem using Rules 6.x-1.2. If I use a token I have the exact same problem as the OP in Post #2. If I put in a static URL (ex http://google.com) I get a redirect loop warning from my browser.

hampshire’s picture

Status: Active » Postponed (maintainer needs more info)

edit- The problem with hundred of nodes being created was caused by an unrelated issue I believe.

I also just noticed something else. Before the redirect I am having a new node created on view. There are hundreds of these new nodes being created for every time I get stuck in the loop. Are you also having rules create a new node before doing the redirect to an external url.

In other words.
When content type 1 is viewed
1-rules creates a node for content type 2
2-rules populates a field in the new content type 2 node
3-rules then redirects to external url

The first 2 steps work fine on their own and with 3 if the external url is a token but (it does not actually go to external url but rather has the problem talked about in post #2).
The first 2 steps seem to get stuck in a loop if step 3 is an external url specified with an acual url like http://google.com (it does not ever go to google.com but rather the browser reports it is stuck in a loop)

Any of this similar with the OP?

hampshire’s picture

Status: Postponed (maintainer needs more info) » Active
webwriter’s picture

I'm only trying to redirect to an external url when the node is saved, sending some variables via a tokenized URL to populate a simple shopping cart that I already use, so I don't have any new nodes being created.

The tokenized url comes out fine but it drops the domain and tld, forcing it to be a relative URL which of course, leads to a page not found error.

I am hosted on an Aegir/NGINX platform, I wonder if that has anything to do with it?

hampshire’s picture

Okay, well I like you have the problem where the tokenized url drops the domain and tld. Its not just you and I am using centos.

hampshire’s picture

Category: support » bug
Status: Postponed (maintainer needs more info) » Active

Is this still a problem for you webwriter or were you able to get it working? I am still having the same problem and can not figure out what could be causing it. Does anyone have any pointers as external urls do not work as page redirects in any of the rules I have and I have no idea where to look for a fix. If anyone needs additional info I will try to provide it.

webwriter’s picture

Sorry, Hampshire. I still cannot get it to work. I am in the process of changing hosts and will be back to trying to beat my head on the wall over this one within a few days. It is critical my processes, so I have to find an answer soon.

hampshire’s picture

Priority: Normal » Major

Here are some other things I have noticed while trying to get this to work, hopefully they can key someone in as to what may be wrong.

I was going to try redirecting so that my link would look like http://mydomain.com/go/http://www.external-domain.com/whatever/else and then have htaccess take it from there as a temporary work around.

PAGE REDIRECT VALUE USED -> LOCATION ACTUALLY TAKEN TO = (WHAT WENT WRONG)

Here is what I expected to happen:
TO: [token] -> http://www.external-domain.com/whatever/else

Here is what is happening:

To: [token] -> http://mydomain.com//whatever/else = (http://www.external-domain.com is stripped)

To: go/[token] -> http://mydomain.com//http%3A/%252Fwww.external-domain.com/whatever/else = (the go is stripped and :// portion of http:// changed)

To: go -> http://domain.com/go = (seems to work fine)

To: /go/[token] -> http://mydomain.com = (receive warning below)

•warning: parse_url(/go/http://www.external-domain.com/whatever/else) [function.parse-url]: Unable to parse URL in /home/.../includes/common.inc on line 327.
•warning: extract() [function.extract]: First argument should be an array in /home/.../includes/common.inc on line 327.

To: /go -> http://domain.com//go is reached = (works as expected)

To: go
?: [token] -> I end up at http://mydomain.com//%252Fwww.external-domain.com/whatever/else = (go is stripped, http:// section is changed and ? is removed)

To: [token
?: [token] -> http://mydomain.com//whatever/else?http://www.external-domain.com/whatev... = (first token's http://www.external-domain.com is stripped and second token works fine)

In every situation I stay at http://mydomain.com instead of being taken offsite.

Also if I try using an external link as a login destination (http://mydomain.com/user?destination=http://external-domain.com/whatever...) I get a 404 error.

Hope all of that helps someone understand what is going on as I have not a clue.

webwriter’s picture

hampshire-

According to http://groups.drupal.org/node/95259, Rules redirect is not capable of redirecting to an external URL, despite the fact that the label in the module tells you it can.

Enter a Drupal path, path alias, or external URL to redirect to. Enter (optional) queries after "?" and (optional) anchor after "#"

The use of the drupal_goto forces an internal URL, no matter what you put in the field. If I figure out a workaround, I'll let you know.

hampshire’s picture

Thank you for the update.

fago’s picture

Status: Active » Closed (cannot reproduce)

As this bug-report is rather old, please verify it's still valid in the latest dev version and re-open if so. For now, I'm marking it as closed.

hampshire’s picture

Status: Closed (cannot reproduce) » Active

I just checked this and it is still valid, I am not trying to do this anymore but I am sure others are.

pgillis’s picture

I'm trying to redirect to an external url to no avail as well.

mitchell’s picture

Version: 6.x-1.x-dev » 7.x-2.x-dev
Priority: Major » Normal
Status: Active » Postponed

Confirmed in 7.x. Likely cause is #337261: parse_url in drupal_goto breaks destination url. Marking is postponed since there is nothing to do here until that issue is fixed.

fago’s picture

Version: 7.x-2.x-dev » 6.x-1.4
Priority: Normal » Major
Status: Postponed » Active

I've just verified that it is working in d7 now, see http://drupal.org/node/1024306#comment-4070132.
However, I assume the security fix witch made the destination parameter not accept external URLs has broken the action in d6 too. So setting back to d6.

fago’s picture

Status: Active » Closed (fixed)

Close due to long inactivity. Please don't hesitate to re-open if the issue is still relevant.