1 comment

  1. Well, I built a multisite, mysite.com composed of mysite.com/subsite1, mysite.com/subsite2… and use Theme my Login plugin.
    As I wanted all the login requests to be sent to mysite.com/login, I found a rewrite rule to acheive that:

    RewriteRule ^(.*)/login/$ http://mysite.com/login/ [L,QSA,NE]
    

    Basically, after my readings and anderstanding, this ^(.*)/ will find any url with ‘login’ in mysite.com and subsites, and redirect it to mysite.com/login.
    Explaining the flags from: http://httpd.apache.org/docs/current/rewrite/flags.html:

    “The [L] flag causes mod_rewrite to stop processing the rule set. In most contexts, this means that if the rule matches, no further rules will be processed.”
    “With the [QSA] flag, a request for /pages/123?one=two will be mapped to /page.php?page=123&one=two. Without the [QSA] flag, that same request will be mapped to /page.php?page=123 – that is, the existing query string will be discarded.”
    “Using the [NE] flag prevents (special characters, such as & and ?, for example, from being converted to their hexcode equivalent.
    RewriteRule ^/anchor/(.+) /bigpage.html#$1 [NE,R]. This example will redirect /anchor/xyz to /bigpage.html#xyz. Omitting the [NE] will result in the # being converted to its hexcode equivalent, %23, which will then result in a 404 Not Found error condition.”

    The combination of those rules will send a user to mysite.com/login, then redirect them to the previous page after login.

    I hope my explanation is helpful -;)

Comments are closed.