I am trying to add www to my domain. I have the custom PHPcode on live server. I have workout GoDaddy forward options also but still my domain not forward. I have a site designed in Core PHPand was wondering how to automatically Add the www prefix to my domain? I have already tried with GoDaddy Forward but still my domain can't redirect: Also .htaccess not working.

My server configurations:

  • GoDaddy + Amazon ec2 (Httpd(RHEL))
  • mod_rewrite enabled
  • Enabled in etc/httpd/conf/httpd.conf: AllowOverride All

How do I change http://example.com to http://www.example.com for my site?

  • Did you add www in Wordpress Address URL and Site Address URL ?? – Helping Hands Dec 18 '14 at 5:15
  • Surprisingly to me, I could not find another question on this site that asks this directly and has a good answer. – Stephen Ostermiller Dec 18 '14 at 11:20

From What are the most commonly used and basic Apache htaccess redirects? contributed by bybe:

Catch all and redirect non-www to www

You should opt to use mod_write for redirecting all requests for non www versions of your site because the $1 varible will catch page names, so example.com/page1/ will automaticly redirect to www.example.com/page1/.


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


<If "%{HTTP_HOST} != 'www.example.com'">
    Redirect permanent / http://www.example.com/
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.