Mobile app version of vmapp.org
Login or Join
Gloria169

: How to add the ‘www’ prefix to my domain 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

@Gloria169

Posted in: #AmazonAws #AmazonEc2 #Apache #HttpdConf #ModRewrite

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 example.com to www.example.com for my site?

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Gloria169

1 Comments

Sorted by latest first Latest Oldest Best

 

@Megan663

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 varible will catch page names, so example.com/page1/ will automaticly redirect to example.com/page1/.
mod_rewrite:

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


mod_alias:

<If "%{HTTP_HOST} != 'www.example.com'">
Redirect permanent / www.example.com/ </If>

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme