Title: Redirection plugin and regular expressions
Last modified: August 20, 2016

---

# Redirection plugin and regular expressions

 *  Resolved [Mark Ratledge](https://wordpress.org/support/users/songdogtech/)
 * (@songdogtech)
 * [14 years, 8 months ago](https://wordpress.org/support/topic/redirection-plugin-and-regular-expressions/)
 * Is there anyone good with regular expressions used by the Redirection plugin 
   [http://urbangiraffe.com/plugins/redirection/](http://urbangiraffe.com/plugins/redirection/)
   who can show me what to use in order to redirect all URLs from a folder to the
   domain root?
 * I.e., an page in in /oldsite/ like /oldsite/this-is-my-page.html, /oldsite/this-
   is-my-page-too.html, etc., needs to go to root via a regular expression.
 * This doesn’t want to work:
 *     ```
       Source: ^oldsite/(.*)
       Target: http://mydomain.com
       ```
   

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

 *  [Paul Vickery](https://wordpress.org/support/users/paul-vickery/)
 * (@paul-vickery)
 * [14 years, 8 months ago](https://wordpress.org/support/topic/redirection-plugin-and-regular-expressions/#post-2311252)
 * I think your problem could be that you are trying to match “^oldsite/(.*)” rather
   than “^/oldsite/(.*)”. I don’t bother using ^ in my matches though.
 * Also, you may find it useful to include the actual old page in the new url as
   a query string, as you’ve tagged it, something like:
 * [http://mydomain.com/?redir=$1](http://mydomain.com/?redir=$1)
 * You can then see your redirections in Google analytics etc.
 * So try:
 *     ```
       Source: ^/oldsite/(.*)
       Target: http://mydomain.com/?redir=$1
       ```
   
 * I found a really nice regex cheat sheet the other day at [http://www.addedbytes.com/cheat-sheets/regular-expressions-cheat-sheet/](http://www.addedbytes.com/cheat-sheets/regular-expressions-cheat-sheet/)
   so it might be worth you printing that out, and experimenting!
 *  Thread Starter [Mark Ratledge](https://wordpress.org/support/users/songdogtech/)
 * (@songdogtech)
 * [14 years, 8 months ago](https://wordpress.org/support/topic/redirection-plugin-and-regular-expressions/#post-2311289)
 * Thanks, was able to get it to work with:
 *     ```
       Source: /oldsite/(.*)
       Target:  http://mydomain.com
       ```
   
 * The extra RegEx in the target resulted in keeping the old URL in the browser 
   bar for some reason.

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

The topic ‘Redirection plugin and regular expressions’ is closed to new replies.

 * 2 replies
 * 2 participants
 * Last reply from: [Mark Ratledge](https://wordpress.org/support/users/songdogtech/)
 * Last activity: [14 years, 8 months ago](https://wordpress.org/support/topic/redirection-plugin-and-regular-expressions/#post-2311289)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
