Support » Plugin: Redirection » Redirectring and preserving REQUEST_URI variable

  • I have setup the redirection plugin and have it working great, but I’m running into a problem in a special instance.

    I have a page called /horse-ad/ that has a special template assigned to it. It pulls from another database some horse details based on the horse that is requested.

    Currently to get to one of these pages you would use the url: /american-quarter-horse-for-sale-in-california/tap-dancin-playboy for example. I have the redirect working to send it to /horse-ad/ using a pass-through. This way I can preserve that longer URL that is descriptive about the ad, however, my REQUEST_URI variable is now just showing /horse-ad/ instead of the long version.

    I need to be able to get access to the last part of that URL as it is the horses name (“tap-dancin-playboy”). Without it, I can’t look it up in the database.

    Here is the Redirection REGEX I am using. Any help with me figuring out how to fix this would be greatly appreciated. I feel like I’m close, just missing something.

    Source URL: ^(.*)for-sale-in(.*)\/(.*)$

    I tried using $1 at the end and $2 but that didn’t seem to produce anything.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Ok.. an update on what I have figured out so far.

    I am now using /horse-ad/$3 which is producing this in the logs: /horse-ad/tap-dancin-playboy. This would be acceptable except it makes WP think there should be a page for /tap-dancin-playboy when in fact that is my variable I’m passing to my script.

    How can I work around that so that WP won’t be trying to find a page for this instance?

    I’m thinking the better solution for me in this case is to determine how to preserve the REQUEST_URI variable in PHP to what it should be originally.. /american-quarter-horse-for-sale-in-california/tap-dancin-playboy

    Any thoughts on that? Or is there another variable I can use that does have that preserved that I’m not aware of?

    The solution for me ended up being using the $3 to detect the name of the horse and then use that as a query string into my page. So the result was that original URL stayed in the address bar but wordpress sent it to the page /horse-ad/?horsesName=asdf

    Hope that helps anyone else out there trying to sort these things out. The trick is the query string instead of using it as a clean URL. Otherwise, WordPress looks for that page and can’t find it so it returns nothing.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Redirectring and preserving REQUEST_URI variable’ is closed to new replies.