Title: [Plugin: Redirection] Help with regular expression
Last modified: August 19, 2016

---

# [Plugin: Redirection] Help with regular expression

 *  Resolved [Gavin Wray](https://wordpress.org/support/users/gavinwray/)
 * (@gavinwray)
 * [15 years, 1 month ago](https://wordpress.org/support/topic/plugin-redirection-help-with-regular-expression/)
 * Hello,
 * I’m trying to do a catchall redirect so users landing on [http://mydomain.com/](http://mydomain.com/)
   are redirected to another domain – yet still allow access to the WP admin areas:
 * [http://mydomain.com/wp-login.php](http://mydomain.com/wp-login.php)
    [http://mydomain.com/wp-admin/anything](http://mydomain.com/wp-admin/anything)
 * Please can anyone help me write a regular expression to do this? My thinking 
   is: redirect any URL that does NOT start with [http://mydomain.com/wp](http://mydomain.com/wp).
   This is the closest I’ve got (with someone else’s help):
 * `/(?!wp)(.*)`
 * This redirects the front-end ok, allows me to view wp-login.php, login and then
   I get stuck in the redirect loop:
 * > This webpage has a redirect loop
   >  The webpage at [http://mydomain.com/wp-login.php?redirect_to=http%3A%2F%2Fdomain.com%2Fwp-admin%2F&reauth=1](http://mydomain.com/wp-login.php?redirect_to=http%3A%2F%2Fdomain.com%2Fwp-admin%2F&reauth=1)
   > has resulted in too many redirects. Clearing your cookies for this site or 
   > allowing third-party cookies may fix the problem. If not, it is possibly a 
   > server configuration issue and not a problem with your computer.
 * Thanks in advance for any ideas.

Viewing 1 replies (of 1 total)

 *  Thread Starter [Gavin Wray](https://wordpress.org/support/users/gavinwray/)
 * (@gavinwray)
 * [15 years, 1 month ago](https://wordpress.org/support/topic/plugin-redirection-help-with-regular-expression/#post-2025134)
 * Apologies. After some more testing across different browsers it seems that the
   expression is working ok.
 * Google Chrome on Mac doesn’t like it – but Firefox and Safari are ok.

Viewing 1 replies (of 1 total)

The topic ‘[Plugin: Redirection] Help with regular expression’ 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/)

 * 1 reply
 * 1 participant
 * Last reply from: [Gavin Wray](https://wordpress.org/support/users/gavinwray/)
 * Last activity: [15 years, 1 month ago](https://wordpress.org/support/topic/plugin-redirection-help-with-regular-expression/#post-2025134)
 * Status: resolved