WordPress.org

Ready to get started?Download WordPress

Forums

Redirection
[resolved] Help with regular expression (2 posts)

  1. Gavin Wray
    Member
    Posted 3 years ago #

    Hello,

    I'm trying to do a catchall redirect so users landing on 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-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. 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 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.

  2. Gavin Wray
    Member
    Posted 3 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic