Title: Help with unwanted redirection
Last modified: August 21, 2020

---

# Help with unwanted redirection

 *  [PBenz](https://wordpress.org/support/users/pbenz/)
 * (@pbenz)
 * [5 years, 9 months ago](https://wordpress.org/support/topic/help-with-unwanted-redirection/)
 * Hello, several years ago, I developed a simple plugin to display an archive of
   PDF files grouped by year. While I can’t pinpoint the exact time it stopped working,
   it was definitely within the past few months. The problem is that an unwanted
   redirect is happening before my plugin even sees the URL.
 * If you visit this URL: /profile/, you’ll see a list of years on the right hand
   side. Every single one of those links simply adds a year to the URL. For example:/
   profile/2018/, but it redirects back /profile/ every time.
 * As I mentioned, this only started happening recently, so I’m wondering if anyone
   might know where this redirect is coming from. I’ve tried the Redirection plugin
   in the hopes that it would log the redirect, but it did not. I understand that
   this might be a problem with the theme (Divi), but I thought I’d ask here first.
    -  This topic was modified 5 years, 9 months ago by [Jan Dembowski](https://wordpress.org/support/users/jdembowski/).
      Reason: Moved to Fixing WordPress, this is not an Developing with WordPress
      topic
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fhelp-with-unwanted-redirection%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [5 years, 9 months ago](https://wordpress.org/support/topic/help-with-unwanted-redirection/#post-13313882)
 * I believe it is `redirect_canonical()`. It’s redirecting because it cannot find
   a sub-page /profile/2018/, so it’s serving the closest fit it can find. You can
   likely suppress the behavior through a filter by the same name. It’s kind of 
   a hacky solution though. What you want is a rewrite rule that explicitly defines
   the URL structure you want and rewrites the request as an URL query string, for
   example `index.php?pagename=profiles&p-year=2018`.
 * The “profiles” page would be based on a custom template that gets the “p-year”
   query var and does something to fulfill the request for that year. I purposely
   used “profiles” plural to differentiate from the existing page, but the “profile”
   page template could handle this just as easily. If there is no p-year query var,
   it does what it does now. If there is a query var, it can do something else.
 *  Thread Starter [PBenz](https://wordpress.org/support/users/pbenz/)
 * (@pbenz)
 * [5 years, 9 months ago](https://wordpress.org/support/topic/help-with-unwanted-redirection/#post-13319094)
 * Thank you, bcworkz. After playing around with this a bit, I think you are correct
   in that this is related to redirect_canonical(). What’s disheartening is that
   these pages were working just fine for the past 5 years or so – this only started
   happening recently.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Help with unwanted redirection’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [PBenz](https://wordpress.org/support/users/pbenz/)
 * Last activity: [5 years, 9 months ago](https://wordpress.org/support/topic/help-with-unwanted-redirection/#post-13319094)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
