0

I want to redirect non-www URL to www URL in WordPress.

I added code for the redirect but I see that I only redirect URL internally but not accessible from the externally. I redirect to apache default page

I added coed in .htaccess.

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{HTTP_HOST} !^www\. [NC]
    RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
</IfModule>

Not work externally. I also set www in secure/non-secure URL.

Does have any solution?

1 Answers1

1

I redirect to apache default page

From our discussion in chat, it would seem that example.com is not accessible from external requests and is not even reaching the server. Whilst www.example.com is accessible and accesses the site OK.

This would seem to suggest there is a DNS issue. There should be an A record that points the domain apex (example.com) to your server's IP address. The server must also be configured to accept requests at this host - but this looks as if it should already be configured since local requests work OK.

MrWhite
  • 13,315