1

On my search results page I am testing to see if there is only one result and if so redirecting the user to that result page using the redirect tag.

However, even though the path I am redirecting to is absolute it seems to be handled as relative.

For example - the path I am redirecting to:

http://myurl.com/path/to/page

Once the redirect is complete the address bar shows:

http://myurl.com/http://myurl.com/path/to/page

This does still show the right page content, but clearly isn't the right URL.

The code i am using is:

{redirect="{url_title_path='store/product'}"}. 

When placed into a template alone {url_title_path='store/product'} writes out myurl.com/path/to/page and indeed this very same tag works perfectly when applied to an anchor (a) tag.

Any advise on how to resolve this much appreciated.

2 Answers 2

1

Well, you shouldn't add the domain on redirect global variable.

{redirect='template_group/template_or_segment_2'}

So, your option is to try:

{redirect='store/product/{url_title}'}

I have to confess that I never tried to use three segments on redirect global variable.

5
  • Thanks Robson, I haven't manually entered the domain. I am using the following code: {redirect="{url_title_path='store/product'}"}. When placed into a template alone {url_title_path='store/product'} writes out myurl.com/path/to/page and indeed this very same tag works perfectly when applied to an anchor (a) tag.
    – Tomtids
    Aug 7, 2013 at 12:33
  • Please, edit your question to inform this. I gonna update my answer.
    – Sobral
    Aug 7, 2013 at 12:39
  • Cheers Robson, I have updated my question.
    – Tomtids
    Aug 9, 2013 at 10:56
  • Please, mark the right answer.
    – Sobral
    Aug 9, 2013 at 12:50
  • Hi Robson... I"m not sure that I have had a correct answer yet!
    – Tomtids
    Aug 30, 2013 at 16:14
1

Consider using the RedirectURL plug-in from Rodrigo Passos. It allows you to specify an entire absolute URL.

This would allow you to provide a URL in something like this: {exp:redirecturl url=“http://myurl.com/{channel_short_name}/{url_title}”}

Or if you're using page URIs: {exp:redirecturl url=“http://myurl.com{page_uri}”}

Find more information about RedirectURL on Devot-ee.

Doing this though, you may want to wrap your conditional in a {exp:ifelse} tag using Croxton's IfElse plug-in. That way you can be sure your condition isn't parsed after the plugin has already run.

1
  • I'm grateful for your answer - and I may well resort to doing it this way, but this surely must be possible without resorting to another plugin?
    – Tomtids
    Aug 9, 2013 at 14:24

Your Answer

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

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