Title: Redirect using Regex
Last modified: October 14, 2020

---

# Redirect using Regex

 *  Resolved [freemason](https://wordpress.org/support/users/freemason/)
 * (@freemason)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/redirect-using-regex/)
 * Hi,
 * I need tho change my permalinks from domain/category/postname to domain/postname.
   Unfortunatelly I dont have thecnical knowledge to do it myself. Can anybody help
   me writing the proper regex code? I would be fantastic if it could be AMP aware.
 * Best regards
    A Jorge
    -  This topic was modified 5 years, 6 months ago by [freemason](https://wordpress.org/support/users/freemason/).

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

 *  Plugin Author [Rank Math SEO](https://wordpress.org/support/users/rankmath/)
 * (@rankmath)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/redirect-using-regex/#post-13538343)
 * Hello [@freemason](https://wordpress.org/support/users/freemason/)
 * Thank you for your message.
 * Firstly, we do not recommend changing the permalink URL structure if your website
   is already getting some traffic and the pages are indexed. The URL structure 
   does not have any direct impact on the rankings.
 * But if you still want to change the structure, you can do that from here:
    `/
   wp-admin/options-permalink.php` WP Dashboard > Settings > Permalink Settings 
   [https://i.rankmath.com/wg3pSi](https://i.rankmath.com/wg3pSi)
 * Hope that helps.
 *  Thread Starter [freemason](https://wordpress.org/support/users/freemason/)
 * (@freemason)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/redirect-using-regex/#post-13538697)
 * HI,
 * Thank you for your prompt answer. However, my problem is not on where to change
   the permalinks. My problem is on the proper Regex expression to turn the current
   permalink (domain/category/post) into the new permalink (domain/post). I need
   to find the proper Regex expression to remove the Category from the permalink.
 * I tryed teh follwing but it doesn work:
 * Source: ^/.*?/(.*)
    Target: /$1/
 * Can you help me on this?
 * Regards
    A Jorge
 *  Plugin Author [Rank Math SEO](https://wordpress.org/support/users/rankmath/)
 * (@rankmath)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/redirect-using-regex/#post-13548134)
 * Hello [@freemason](https://wordpress.org/support/users/freemason/)
 * Please try the following pattern:
    Source: `^[^/]+/([^/]+)/?$` Destination: `
   $1`
 * Hope that helps. Thank you.

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

The topic ‘Redirect using Regex’ is closed to new replies.

 * ![](https://ps.w.org/seo-by-rank-math/assets/icon.svg?rev=3438330)
 * [Rank Math SEO – AI SEO Tools to Dominate SEO Rankings](https://wordpress.org/plugins/seo-by-rank-math/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/seo-by-rank-math/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/seo-by-rank-math/)
 * [Active Topics](https://wordpress.org/support/plugin/seo-by-rank-math/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/seo-by-rank-math/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/seo-by-rank-math/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [Rank Math SEO](https://wordpress.org/support/users/rankmath/)
 * Last activity: [5 years, 6 months ago](https://wordpress.org/support/topic/redirect-using-regex/#post-13548134)
 * Status: resolved