Title: Redirect loop
Last modified: January 5, 2021

---

# Redirect loop

 *  Resolved [gsibert](https://wordpress.org/support/users/gsibert/)
 * (@gsibert)
 * [5 years, 5 months ago](https://wordpress.org/support/topic/redirect-loop-95/)
 * Having trouble getting a regex to work. The old url was something like /alabama/
   and it’s moving to /new-slug/alabama/
 * If it was just 1 it would be simple but let’s say it’s all the states.
 * From:
    /(alabama|alaska|arizona|arkansas|california|colorado|connecticut|delaware
   |florida|georgia|hawaii|idaho|illinois|indiana|iowa|kansas|kentucky|louisiana
   |maine|maryland|massachusetts|michigan|minnesota|mississippi|missouri|montana
   |nebraska|nevada|newhampshire|newjersey|newmexico|newyork|northcarolina|northdakota
   |ohio|oklahoma|oregon|pennsylvania|rhodeisland|southcarolina|southdakota|tennessee
   |texas|utah|vermont|virginia|washington|westvirginia|wisconsin|wyoming)
 * To:
    /new-slug/$1
 * end up with:
    /new-slug/new-slug/new-slug/new-slug/new-slug/new-slug/
 * I’m sure I’m missing something in the from regex, maybe?

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

 *  Plugin Contributor [Jeffrey Paul](https://wordpress.org/support/users/jeffpaul/)
 * (@jeffpaul)
 * [5 years, 5 months ago](https://wordpress.org/support/topic/redirect-loop-95/#post-13868902)
 * [@gsibert](https://wordpress.org/support/users/gsibert/) I’d recommend checking
   out the linked [great tutorials](https://www.regular-expressions.info/) on regular
   expressions from the readme. Good luck!
 *  Thread Starter [gsibert](https://wordpress.org/support/users/gsibert/)
 * (@gsibert)
 * [5 years, 5 months ago](https://wordpress.org/support/topic/redirect-loop-95/#post-13868908)
 * I’ve been reading those for 2 hours… thanks for the helpful tip.
 *  Thread Starter [gsibert](https://wordpress.org/support/users/gsibert/)
 * (@gsibert)
 * [5 years, 5 months ago](https://wordpress.org/support/topic/redirect-loop-95/#post-13869770)
 * Since support is so useful here, I’ll post what I found to work after spending
   the rest of the day… when you suck at regex it takes all day to figure 9 characters:
 * ^[^\/]?\/(alabama|alaska|arizona|arkansas|california|colorado|connecticut|delaware
   |florida|georgia|hawaii|idaho|illinois|indiana|iowa|kansas|kentucky|louisiana
   |maine|maryland|massachusetts|michigan|minnesota|mississippi|missouri|montana
   |nebraska|nevada|newhampshire|newjersey|newmexico|newyork|northcarolina|northdakota
   |ohio|oklahoma|oregon|pennsylvania|rhodeisland|southcarolina|southdakota|tennessee
   |texas|utah|vermont|virginia|washington|westvirginia|wisconsin|wyoming)
 * in the to:
 * /your-slug/$1
 * The upper query only grabs the states at the root URL, not query strings or other
   slugs. That’s what was causing my loop.

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

The topic ‘Redirect loop’ is closed to new replies.

 * ![](https://ps.w.org/safe-redirect-manager/assets/icon.svg?rev=2791413)
 * [Safe Redirect Manager](https://wordpress.org/plugins/safe-redirect-manager/)
 * [Support Threads](https://wordpress.org/support/plugin/safe-redirect-manager/)
 * [Active Topics](https://wordpress.org/support/plugin/safe-redirect-manager/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/safe-redirect-manager/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/safe-redirect-manager/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [gsibert](https://wordpress.org/support/users/gsibert/)
 * Last activity: [5 years, 5 months ago](https://wordpress.org/support/topic/redirect-loop-95/#post-13869770)
 * Status: resolved