Title: regex help
Last modified: August 19, 2016

---

# regex help

 *  Resolved [milo2man](https://wordpress.org/support/users/milo2man/)
 * (@milo2man)
 * [17 years, 5 months ago](https://wordpress.org/support/topic/regex-help/)
 * I am trying to set up permanent redirects so that a link to
    [http://www.example.com/blog/post-title/](http://www.example.com/blog/post-title/)
   would be redirected to [http://www.example.com/post-title/](http://www.example.com/post-title/)
 * I have in my .htaccess the following
 * `RewriteRule blog/([A-Za-z0-9]+)$ /$1 [R=301,L]`
 * which doesn’t work (returns a 404).
 * However, if I add a manual redirect such as
 * `RewriteRule blog/post-title/ /post-title/ [R=301,L]`
 * this works.
 * I must be doing something wrong with the REGEX syntax. Can anyone help me out?

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

 *  [whooami](https://wordpress.org/support/users/whooami/)
 * (@whooami)
 * [17 years, 5 months ago](https://wordpress.org/support/topic/regex-help/#post-920247)
 * I love .*
 * `RewriteRule blog/.*$ /$1 [R=301,L]`
 * that would match pretty much anything you put after blog/
 *  [whooami](https://wordpress.org/support/users/whooami/)
 * (@whooami)
 * [17 years, 5 months ago](https://wordpress.org/support/topic/regex-help/#post-920265)
 * hmm, thats not going to work.
 *  [whooami](https://wordpress.org/support/users/whooami/)
 * (@whooami)
 * [17 years, 5 months ago](https://wordpress.org/support/topic/regex-help/#post-920267)
 * ok, i tested this one:
 * `RewriteRule ^blog/(.*)$ /$1 [R=301,L]`
 *  Thread Starter [milo2man](https://wordpress.org/support/users/milo2man/)
 * (@milo2man)
 * [17 years, 5 months ago](https://wordpress.org/support/topic/regex-help/#post-920298)
 * Thanks for the help. I tried these and finally managed to get it to work using
 * `RewriteRule blog/([A-Za-z0-9-]+)/$ /$1/ [R=301,L]`
 * The problem was the missing / after each expression.

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

The topic ‘regex help’ is closed to new replies.

## Tags

 * [regex](https://wordpress.org/support/topic-tag/regex/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 4 replies
 * 2 participants
 * Last reply from: [milo2man](https://wordpress.org/support/users/milo2man/)
 * Last activity: [17 years, 5 months ago](https://wordpress.org/support/topic/regex-help/#post-920298)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
