WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] primary domain problems. NON-canonical address propagates to ''site ... does not (7 posts)

  1. seito
    Member
    Posted 2 years ago #

    Hy guys. I'm running in circles here and really don't know what to do! Any help would be much appreciated...

    I changed my existing wp installation in to network. And now I have problems with primary domain.

    When I type domain with WWW (www.anteros.eu) everything is OK.

    But if I type just anteros.eu all hell breaks lose :)! I get this error message:

    You are logged in already. No need to register again!
    The site you were looking for, http://anteroseu.www.anteros.eu/, does not exist.

    from anteroseu.www.ant.... looks like wp is taking non canonical URL as subdomain.

    I tried to play around with redirections in my cPanel and .htaccess redirections to wwww, but nothing worked so far.

    Before network installation everything worked fine. And I choose sub-domain type. Also, my other site (used MU domain mapping plugin to map both www and no www domains), which was a whole reason for changing to network works just fine with www or without www.

    Please, can anybody help me?

  2. grosshat
    Member
    Posted 2 years ago #

    Maybe I am missing something, but I cannot reproduce the issue for 'anteros.eu'. It redirects to 'www.anteros.eu'. Is it right?

  3. seito
    Member
    Posted 2 years ago #

    First, thank you for your time!

    Strange. Try this:
    1. enter URL -> anteros.eu (I tried in another browser and in mozila it did redirected me to http://www.anteros.eu)
    2. when you have http://www.anteros.eu in address bar, highlite and delete "www." part of URL.
    3. I get redirected to http://anteroseu.www.anteros.eu/ as before.

    When typing anteros.eu in Chrome's address bar, problem above is immediate.

    Any idea what could be going on?

  4. When you turned on Multisite, you were warned not to use www in the domain name.

    The easiest fix would be to use .htaccess and force www all the time.

  5. seito
    Member
    Posted 2 years ago #

    Yes I was. But I used my www for 2+ years and all the links and ... well, you know. Standard excuses for taking a shortcut that later on bites you in your back.

    I tried redirecting non www to www from my cPanel. No success.

    Also i tried redirecting with .htaccess. But it seems I can't make it work. There is something wrong with my code... At the moment in my root I have htaccess with:

    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    
    # uploaded files
    RewriteRule ^files/(.+) wp-includes/ms-files.php?file=$1 [L]
    
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ - [L]
    RewriteRule . index.php [L]
    
    RewriteCond %{HTTP_HOST} !^www\.
    RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

    Do you have any idea what could be wrong?

  6. seito
    Member
    Posted 2 years ago #

    ok. I made it work. Problem was, in sequence of redirections... When I moved my non www -> www redirection right after rewrite base / things started to work as they should.

    This is my code now, for root htaccess on sub-domain multisite network where primary domain is www. For future references. And if anybody sees any mistake, or has any suggestions, I will be grateful for information.

    RewriteEngine On
    RewriteBase /
    
    RewriteCond %{HTTPS} off
    RewriteCond %{HTTP_HOST} !^www\.(.*)$ [NC]
    RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
    
    RewriteCond %{HTTPS} on
    RewriteCond %{HTTP_HOST} !^www\.(.*)$ [NC]
    RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]
    
    RewriteRule ^index\.php$ - [L]
    
    # uploaded files
    RewriteRule ^files/(.+) wp-includes/ms-files.php?file=$1 [L]
    
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ - [L]
    RewriteRule . index.php [L]
  7. seito
    Member
    Posted 2 years ago #

    THIS IS MAKING ME GO CRAZY! Sorry guys, but problem is NOT resolved!

    It works so well, that now it redirects everything to http://www.anteros.eu. Even other sites and domains on network! For example, example1.com redirects to http://www.anteros.eu. Also http://www.example1.com. And example1.com is mapped subdomain that I use for another page on network.

    So I added this little line:
    RewriteCond %{HTTP_HOST} !example1.com [NC]

    And it works now. But is there any other way? How do I tell htaccess, that redirection is only valid for this domain, and NO subdomain? As i see it, problem is that example1.anteros.eu is valid for first RewriteCond %{HTTP_HOST} !^www\.(.*)$ [NC]. There is no WWW at the beginning and so it redirects to http://www.anteros.eu.

    But how to rewrite this code so that I won't need to ad exceptions like
    !example1.com [NC] for every single subdomain?

    Any suggestions?

Topic Closed

This topic has been closed to new replies.

About this Topic