As the title says, i'm trying to create a redirect from mydomain.com to www.mydomain.com. I've attempted to edit htaccess_dist and i've also tried to add a new htaccess with the following code
RewriteEngine on
rewritecond %{http_host} ^mydomain.com [nc]
rewriterule ^(.*)$ http://www.mydomain.com/$1 [r=301,nc]
I've also tried a few variations of the above code with no luck. Some other points - the site is on a VPS using Apache and i'm NOT sure if mod_rewrite is enabled, that being said, i'm pretty sure mod_rewrite default is "enabled".
Any help would be much appreciated.
info@elgg.org
Security issues should be reported to security@elgg.org!
©2014 the Elgg Foundation
Elgg is a registered trademark of Thematic Networks.
Cover image by RaĆ¼l Utrera is used under Creative Commons license.
Icons by Flaticon and FontAwesome.
- survtime@survtime
survtime - 0 likes
- ghumanz@harinderghumanz
ghumanz - 0 likes
- ghumanz@harinderghumanz
ghumanz - 0 likes
- survtime@survtime
survtime - 0 likes
- ghumanz@harinderghumanz
ghumanz - 0 likes
- survtime@survtime
survtime - 0 likes
- ghumanz@harinderghumanz
ghumanz - 0 likes
- survtime@survtime
survtime - 0 likes
- ghumanz@harinderghumanz
ghumanz - 0 likes
You must log in to post replies.Anyone?
RewriteCond %{HTTP_HOST} ^yoursite.com
RewriteRule (.*) http://www.yoursite.com/$1 [R=301,L]
use above code it will work for you.
should I see the changes immediately? And what is the difference between [nc] or [r=301,nc] and [R=301,L] ?
Thanks for the help - i'll post back with the results.
yes try open your site without www in any browser it will automatically rediect it to www.
this is a copy of code from working site.
Also, do I create a new htaccess file or just copy past the code into htaccess_dist
you need to rename htaccess_dist to .htaccess and copy this code after RewriteEngine on
Your suggestion ended up working perfectly - although I couldn't log into the site, it was like I had never logged in before and had to re-register. Why would this happen?
Not a big problem just paste your code of .htaccess file here. the problem is there.