Title: Regular expression not working
Last modified: September 6, 2021

---

# Regular expression not working

 *  Resolved [Jaap de Wit](https://wordpress.org/support/users/hitec4ever/)
 * (@hitec4ever)
 * [4 years, 9 months ago](https://wordpress.org/support/topic/regular-expression-not-working/)
 * Hi,
 * I’ve created a redirection with a regular expression but it doesn’t seem to work.
 * Source: /nl/search?controller=search&s=(.*)
    Target: /?product_cat=&s=$1&post_type
   =product
 * Not an expert so I must do something wrong. Please assist.
 * Cheers,
    Jaap

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

 *  Plugin Author [John Godley](https://wordpress.org/support/users/johnny5/)
 * (@johnny5)
 * [4 years, 9 months ago](https://wordpress.org/support/topic/regular-expression-not-working/#post-14842851)
 * Please see the guide, specifically the section about testing expressions and 
   escaping characters.
 * [https://redirection.me/support/redirect-regular-expressions/](https://redirection.me/support/redirect-regular-expressions/)
 *  Thread Starter [Jaap de Wit](https://wordpress.org/support/users/hitec4ever/)
 * (@hitec4ever)
 * [4 years, 9 months ago](https://wordpress.org/support/topic/regular-expression-not-working/#post-14843445)
 * Hi John,
 * I’ve read the guide and also tested my expressions on regex101. According regex101
   they should work. I currently have the following non working redirects.
 * source: [\/]nl[\/]search\?controller=search&s=(.*)
    target: /?product_cat=&s=
   $1&post_type=product
 * source: [\/]nl[\/]order-confirmation\?.*
    target: /
 * source: [\/]nl[\/]index.php\?.*
    target: /
 * Cheers,
    Jaap
 *  Thread Starter [Jaap de Wit](https://wordpress.org/support/users/hitec4ever/)
 * (@hitec4ever)
 * [4 years, 9 months ago](https://wordpress.org/support/topic/regular-expression-not-working/#post-14843501)
 * Changed them to this but still not working (the search one is working now):
 * source: \/nl\/order-confirmation\?.*
    target: /
 * source: \/nl\/index.php\?.*
    target: /
 * Regex option has been set btw.
 * Example url: [https://www.carpwhisperer.com/nl/index.php?controller=order-detail&id_order=24939](https://www.carpwhisperer.com/nl/index.php?controller=order-detail&id_order=24939)
 * and: [https://www.carpwhisperer.com/nl/order-confirmation?id_cart=49567&id_module=28&id_order=25719&key=45e27f206a9398d94ac06b244275dea9](https://www.carpwhisperer.com/nl/order-confirmation?id_cart=49567&id_module=28&id_order=25719&key=45e27f206a9398d94ac06b244275dea9)
 * Cheers,
    Jaap
    -  This reply was modified 4 years, 9 months ago by [Jaap de Wit](https://wordpress.org/support/users/hitec4ever/).
 *  Plugin Author [John Godley](https://wordpress.org/support/users/johnny5/)
 * (@johnny5)
 * [4 years, 9 months ago](https://wordpress.org/support/topic/regular-expression-not-working/#post-14843563)
 * You don’t need to escape the `/` character.
 * Have you cleared your browser cache?
 *  Thread Starter [Jaap de Wit](https://wordpress.org/support/users/hitec4ever/)
 * (@hitec4ever)
 * [4 years, 9 months ago](https://wordpress.org/support/topic/regular-expression-not-working/#post-14843631)
 * Hi, yes cleared my cache and also WpRocket cache. I removed the \ from the source.
 * source: /nl/order-confirmation\?.*
    target: /
 * source: /nl/index.php\?.*
    target: /
 * So this should be ok right? I see an increasing hitscore so they must be working
   I think. The one with order-confirmation does work now but the one with index.
   php doesn’t at my end. Both tested in private browser.
 *  Plugin Author [John Godley](https://wordpress.org/support/users/johnny5/)
 * (@johnny5)
 * [4 years, 9 months ago](https://wordpress.org/support/topic/regular-expression-not-working/#post-14843660)
 * >  but the one with index.php doesn’t at my end
 * Details for that here: [https://redirection.me/support/problems/url-not-redirecting/](https://redirection.me/support/problems/url-not-redirecting/)
 *  Thread Starter [Jaap de Wit](https://wordpress.org/support/users/hitec4ever/)
 * (@hitec4ever)
 * [4 years, 9 months ago](https://wordpress.org/support/topic/regular-expression-not-working/#post-14845384)
 * Hi John,
 * Yes, I need to do this with htaccess I think. Will look into that.
    Thanks for
   your help so far.
 * Cheers,
    Jaap

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

The topic ‘Regular expression not working’ is closed to new replies.

 * ![](https://ps.w.org/redirection/assets/icon-256x256.jpg?rev=983639)
 * [Redirection](https://wordpress.org/plugins/redirection/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/redirection/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/redirection/)
 * [Active Topics](https://wordpress.org/support/plugin/redirection/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/redirection/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/redirection/reviews/)

 * 7 replies
 * 2 participants
 * Last reply from: [Jaap de Wit](https://wordpress.org/support/users/hitec4ever/)
 * Last activity: [4 years, 9 months ago](https://wordpress.org/support/topic/regular-expression-not-working/#post-14845384)
 * Status: resolved