Cross-domain

Discussion in 'Setting-up protection' started by howudodat, May 9, 2008.

  1. howudodat

    howudodat New Member

    Joined:
    May 9, 2008
    Messages:
    1
    We have a website that can be accessed either with:
    www.foo.bar and
    foo.bar

    The protection is set to new_rewrite:
    folder:
    /..../backoffice/
    url:
    http://www.foo.bar/backoffice/

    When a user goes to foo.bar and logs in all is fine and the amember info is stored in $_SESSION as it should be
    When a user goes to www.foo.bar and logs in after login they are redirected to simply foo.bar/backoffice and the $_SESSION variable is blank!
    Here is the enter redirect:
    Code:
    <div class="default-style" id="U395558623FZQ39" style="position:absolute;
    top:150px; left:718px; width:160px; height:78px;">
    <form action="/amember/login.php?url=/backoffice" method=post>
    Username:<input type=text name=amember_login size=10><br>
    Password: <input type=password name=amember_pass size=10><br>
    <input type=submit value=Enter>
    </form>
    </div>
    Any ideas what I've got screwed up?
    Peter
  2. skippybosco

    skippybosco CGI-Central Partner Staff Member

    Joined:
    Aug 22, 2006
    Messages:
    2,526
    Is there a reason to allow both?

    I use this code to force everyone to the non www. domain. It gets added to your .htaccess file in the root of your server:

    Code:
    <IfModule mod_rewrite.c>
    RewriteEngine On
    # If subdomain www exists, remove it first
    RewriteCond %{HTTP_HOST} ^www\.([^\.]+\.[^\.]+)$ [NC]
    RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
    # If requested resource does not exist as a file
    RewriteCond %{REQUEST_FILENAME} !-f
    # and does not end with a period followed by a filetype
    RewriteCond %{REQUEST_URI} !..+$
    # and does not end with a slash
    RewriteCond %{REQUEST_URI} !/$
    # then add a trailing slash and redirect
    RewriteRule (.*) $1/ [R=301,L]
    </IfModule>
  3. davidm1

    davidm1 aMember User & Partner

    Joined:
    May 16, 2006
    Messages:
    4,437
    LOL - I force to the www.


    Code:
    RewriteEngine On
    RewriteCond %{HTTP_HOST} !^www\.yoursite\.com [NC]
    RewriteCond %{HTTP_HOST} !^$
    RewriteRule ^(.*) http://www.yoursite.com/$1 [L,R]

Share This Page