• CZNeo

    (@czneo)


    Howdie,

    I have a multisite with 16 subdomains … the main one is without www at the beggining. Is there any way how to redirect it?

    my htaccess looks like this:

    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    
    # add a trailing slash to /wp-admin
    RewriteRule ^wp-admin$ wp-admin/ [R=301,L]
    
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ - [L]
    RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
    RewriteRule ^(.*\.php)$ $1 [L]
    RewriteRule . index.php [L]
    

    Thank you for the advice.

Viewing 4 replies - 1 through 4 (of 4 total)
  • raimundoz

    (@raimundoz)

    Hello,

    The rules you need to add to the .htaccess is:

    
    RewriteCond %{HTTP_HOST} ^www\.example\.com [NC]
    RewriteRule ^(.*)$ https://example.com/$1 [L,R=301]

    Just replace the “example” with your domain.

    • This reply was modified 8 years ago by raimundoz.
    Thread Starter CZNeo

    (@czneo)

    Thank you for the answer!

    however, it seems as if nothing’s changed. When I put https://www.mydomain.cz in the address bar I am redirected to mydomain.cz

    My goal was to do that the other way round. Anyway, I tried to tweak your code by switching Condition and Rule

    RewriteCond %{HTTP_HOST} ^example\.com [NC]
    RewriteRule ^(.*)$ https://www.example.com/$1 [L,R=301]

    Didn’t work either.

    raimundoz

    (@raimundoz)

    Can you paste the entire code of the .htaccess?

    Thread Starter CZNeo

    (@czneo)

    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    
    # add a trailing slash to /wp-admin
    RewriteRule ^wp-admin$ wp-admin/ [R=301,L]
    
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ - [L]
    RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
    RewriteRule ^(.*\.php)$ $1 [L]
    RewriteRule . index.php [L]
    RewriteCond %{HTTP_HOST} ^zelenenoviny\.cz [NC]
    RewriteRule ^(.*)$ https://www.zelenenoviny.cz/$1 [L,R=301]
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘redirect non-www to www’ is closed to new replies.