Extension, Module

Archived
Forum
(read-only)

Detour Pro

ExpressionEngine 2, ExpressionEngine 3, ExpressionEngine 4, ExpressionEngine 5, ExpressionEngine 6

Back to this add-on's main page
View Other Add-ons From Tom Jaeger

     

Is it possible to redirect and keep the ?id= part

Feature Request

tunnel7
tunnel7

Hi Mike ... I was reading the documentation and I’m close but not quite there, thus the request.

The scenario is I am attempting to redirect:

os/reset_password?&id=BrzVdZhw

to

/reset-password?&id=BrzVdZhw

I was attempting to do this with using the single and double & wildcards and it will work but no matter what I try it chops the ?&id=BrzVdZhw off of the redirect.

Is this possible to keep this part in the redirect using the module? 

Thanks in advance.

cityzen
# 1
cityzen

Hey there -

Currently Detour doesn’t support keeping the query string but let me see what I can do to add that in. Can I loop back around with you on Monday?

Thanks,

Mike

tunnel7
# 2
tunnel7

Of course.  That would be great.  Much appreciated.

tunnel7
# 3
tunnel7

Hi Mike.  Any word / update on this?  Thanks in advance.

cityzen
# 4
cityzen

Yea, I’m testing a way to do this w/out touching the control panel. Thinking about allowing you to add a ? at the end of the redirect to that would indicate you want the query string on there. Would that work?

tunnel7
# 5
tunnel7

Yes, I think something like that would work fine.  I just need from the ? on to stay on the redirected URL.  Thanks for the quick reply.  Will look forward to hearing how it turns out.

cityzen
# 6
cityzen

can you shoot me an email to mike [at] cityzen.com with your ext.detour_pro.php file. Would you be willing to test on your site after I do some local testing?

tunnel7
# 7
tunnel7

As long as you make a backup of the existing file so if something does go haywire we can easily put back in place, I’m fine with that.  Will send email now.

cityzen
# 8
cityzen

I just realized that this should all work fine with the existing ability to include the tail of the redirect. If you want to download the latest version (1.5.1) and set up your redirect like this:

original URL:
os/reset_password%%

detour to:
reset-password

but you also need to go into the Extension settings and set Default URL Detection Method to PHP:
Screenshot: https://www.dropbox.com/s/9posq2bb4018n9u/Screenshot 2015-10-06 17.48.40.png?dl=0

I just tested it locally and it works as expected.

Sorry for the delay on that!

Mike

tunnel7
# 9
tunnel7

OK.  Thanks Mike.  I will get to this later today and will let you know how I make out.

cityzen
# 10
cityzen

No problem. I thought I recalled at some point that there was an issue with query strings but then tested with your example and it worked. You do have to set it to PHP, though.

Let me know how it works out.

tunnel7
# 11
tunnel7

This did the trick!  Thanks for pointing me in a good direction here.

cityzen
# 12
cityzen

Awesome, glad it worked!

tunnel7
# 13
tunnel7

It’s great to have this in place.

Ottergoose
# 14
Ottergoose

I was able to get the query strings working by adding this at line 67 of detour_pro/ext.detour_pro.php v 1.6:

// If a query string is present, append it to new URL
   
if(isset($_SERVER["QUERY_STRING"])){
    
if($_SERVER["QUERY_STRING"!= ''){
     $newUrl 
.= '?' $_SERVER["QUERY_STRING"];
    
}
   } 

This doesn’t require modifying any of the redirect rules, nor enabling the URL detection method in the CP (which didn’t seem to work for us).

It works in my test environment anyways, FYI/FWIW.