• Hello

    i want to do a 301 .htaccess redirect (www to non www)

    I used this code:

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

    but it allways adds ../html on the end of the URL.
    So the redirection leads to https://cashaeon.com/html/

    probably it’s just a small thing, but I did not look through
    hopefully..

Viewing 15 replies - 1 through 15 (of 15 total)
  • Moderator t-p

    (@t-p)

    Check with this code:

    # Redirect www to non-www
    RewriteCond %{HTTP_HOST} ^www\.(.*)
    RewriteRule (.*) https://%1/$1 [R=301,L]

    Thread Starter RoX

    (@144icom)

    Hello

    thanks, i tried it but this code does not work at all.
    No redirection takes place

    Moderator t-p

    (@t-p)

    If it does not work, you are probably missing the RewriteEngine On

    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
    RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
    Thread Starter RoX

    (@144icom)

    yes for sure!

    ok redirection works, but as before ../html and the end of the URL..?!

    Thread Starter RoX

    (@144icom)

    maybe is it a server configuration issue?

    Moderator t-p

    (@t-p)

    ok redirection works, but as before ../html and the end of the URL..?!

    try a few basic troubleshooting steps:
    – Flushing any caching plugins you might be running, as well as server and/or browser caches.
    – deactivating ALL plugins temporarily to see if this resolves the problem (plugin functions can interfere). If this works, re-activate them individually (one-by-one) to find the problematic plugin(s).
    – If that does not resolve the issue, try switching to the unedited default Twenty Fifteen Theme for a moment using the WP dashboard to rule out any theme-specific issue (theme functions can interfere like plugins).

    Moderator t-p

    (@t-p)

    maybe is it a server configuration issue?

    May be. To find out, have a talk with your hosting provider.

    Thread Starter RoX

    (@144icom)

    My hosting provider told me that’s not an issue with server config.

    They gave me this code

    – Redirect 301 per mod_rewrite:
    RewriteEngine On
    RewriteRule ^(.*).html$ https://www.new-domain.com/$1.html [R=301,L]

    not sure about – i tried this – but it does not work:
    RewriteEngine On
    RewriteRule ^(.*).html$ https://cashaeon.com/$1.html [R=301,L]

    Moderator t-p

    (@t-p)

    Have you attempted these basic troubleshooting steps:
    – Flushing any caching plugins you might be running, as well as server and/or browser caches.
    – deactivating ALL plugins temporarily to see if this resolves the problem (plugin functions can interfere). If this works, re-activate them individually (one-by-one) to find the problematic plugin(s).
    – If that does not resolve the issue, try switching to the unedited default Twenty Fifteen Theme for a moment using the WP dashboard to rule out any theme-specific issue (theme functions can interfere like plugins).

    Thread Starter RoX

    (@144icom)

    Hi

    not sure whats going wrong now

    i cannot login anymore. I deleted this htaccess
    but now i allways see this when i try to login …??

    https://cashaeon.com/wp-login.php?redirect_to=http%3A%2F%2Fcashaeon.com%2Fwp-admin%2F&reauth=1

    Moderator t-p

    (@t-p)

    – try resetting the plugins foldervia FTP or SFTP or whatever file management application your host provides. Sometimes, an apparently inactive plugin can still cause problems.

    – If that does not resolve the issue, check the error logs on your server for a more specific error message. If you need help locating them, ask your hosting provider to help you with that.

    – it could be a server configuration issue, but looks like your host does not want to help/investigate

    Thread Starter RoX

    (@144icom)

    it’s strange
    i did all the steps, but it still adds the ../html and the end of the URL

    I already Discussed this issue with my provider, But They gave up .. and have it returned to me .. and they are not ready to continue Support in this matter
    Their strict statement whas that this can be done with .htaccess and there is no server config conflict

    i looked into the log files, but I can not interpret it well

    puhhh..

    Thread Starter RoX

    (@144icom)

    OMG i got it !!

    The Problem was in the confixx Domain Settings. Incorrect path. https://www.cashaeon.com pointed to ../ (the root) and not to the Folder where wp is installed. ../html/../

    3 days!! and i learnd a lot..

    Thanks for your Support!

    Moderator t-p

    (@t-p)

    Glad you got it sorted ??
    Please mark this thread resolved using the dropdown in the sidebar.

    I tried the same on https://www.sonejder.com with the 301 redirection, but the redirection was working before too, without the 301 in the htaccess code. I thaugt that it would be search engine optimized, if I make the change and trid now the code

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

    the problem is, that a seo checker tool is still saying this:

    Warning. Website not www redirected properly.
    Notes: www 301 redirect avoids duplicate content problem which could affect website ranking.

    What can I do?

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘301 .htaccess redirect www to non www’ is closed to new replies.