non www to www redirect – link issue

Hi! I've been trying to fix this issue for a few weeks now, using posts on the forum and from elsewhere to try and address this.

The website I'm working on is http://www.ducksinarow.uk.com – and non www. links redirect to the home page. The issue is that all non-www. direct links to pages or network sites – ducksinarow.uk.com/pennytate (network site) or ducksinarow.uk.com/coaching-areas/adhd (page) redirect to the same home page (www.ducksinarow.uk.com).

Hope this made sense! Also, we are using Cloudflare – configuration is attached. We've spent ages trying to address this and have ran out of ideas now!

  • Jude
    • DEV MAN

    Howdy Chris

    Hope all is well with you !

    Can you paste your .htaccess file here please ?

    Also try adding this to the top of your .htaccess file and see if the pennytale site works fine.

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{HTTP_HOST} www.ducksinarow.uk.com [NC]
    RewriteCond %{REQUEST_URI} ^/pennytate/(.*)
    RewriteRule ^(.*)$ http://ducksinarow.uk.com/$0 [R=301,L]
    </IfModule>

    More info here

    https://codex.wordpress.org/htaccess

    Cheers

    Jude

  • Chris
    • Flash Drive

    Hey Jude!

    I just tried the .htaccess modification and had no luck unfortunately.

    My file currently looks like this (lots of stuff in there from plugins, but I have tried clearing it too!:

    <IfModule mod_rewrite.c>

    RewriteEngine On

    RewriteCond %{HTTP_HOST} http://www.ducksinarow.uk.com [NC]

    RewriteCond %{REQUEST_URI} ^/pennytate/(.*)

    RewriteRule ^(.*)$ http://ducksinarow.uk.com/$0 [R=301,L]

    </IfModule>

    # BEGIN Far Future Expiration Plugin

    <IfModule mod_expires.c>

    ExpiresActive on

    <FilesMatch “.(gif|jpeg|jpg|png|ico|js|css|swf)$”>

    ExpiresDefault “access plus 240 hours”

    </FilesMatch>

    </IfModule>

    # END Far Future Expiration Plugin

    # BEGIN WordPress

    <IfModule mod_rewrite.c>

    RewriteEngine On

    RewriteBase /

    RewriteRule ^index.php$ – [L]

    # add a trailing slash to /wp-admin

    RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]

    RewriteCond %{REQUEST_FILENAME} -f [OR]

    RewriteCond %{REQUEST_FILENAME} -d

    RewriteRule ^ – [L]

    RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]

    RewriteRule ^([_0-9a-zA-Z-]+/)?(.*.php)$ $2 [L]

    RewriteRule . index.php [L]

    </IfModule>

    #force pdf file download

    <FilesMatch “.(?i:pdf)$”>

    ForceType application/octet-stream

    Header set Content-Disposition attachment

    </FilesMatch>

    # END WordPress

    #redirect non www to www.

    RewriteEngine On

    RewriteCond %{HTTP_HOST} ^duckinsarow.uk.com [NC]

    RewriteRule ^(.*)$ http://www.ducksinarow.uk.com/$1 [L,R=302]

    # END redirect module

    # BEGIN BROWSER CACHING

    <IfModule mod_expires.c>

    ExpiresActive On

    ExpiresDefault A0

    <FilesMatch “.(txt|xml|js)$”>

    ExpiresDefault A691200

    </FilesMatch>

    <FilesMatch “.(css)$”>

    ExpiresDefault A691200

    </FilesMatch>

    <FilesMatch “.(flv|ico|pdf|avi|mov|ppt|doc|mp3|wmv|wav|mp4|m4v|ogg|webm|aac)$”>

    ExpiresDefault A691200

    </FilesMatch>

    <FilesMatch “.(jpg|jpeg|png|gif|swf|webp)$”>

    ExpiresDefault A691200

    </FilesMatch>

    </IfModule>

    <IfModule mod_headers.c>

    <FilesMatch “.(txt|xml|js)$”>

    Header set Cache-Control “max-age=691200”

    </FilesMatch>

    <FilesMatch “.(css)$”>

    Header set Cache-Control “max-age=691200”

    </FilesMatch>

    <FilesMatch “.(flv|ico|pdf|avi|mov|ppt|doc|mp3|wmv|wav|mp4|m4v|ogg|webm|aac)$”>

    Header set Cache-Control “max-age=691200”

    </FilesMatch>

    <FilesMatch “.(jpg|jpeg|png|gif|swf|webp)$”>

    Header set Cache-Control “max-age=691200”

    </FilesMatch>

    </IfModule>

    # END CACHING

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.