I would like to modify my .htaccess file so that when someone comes into my site without typing www the site always redirects them to the www version. For example, if my url is www.abc.com and they just type abc.com, I want to redirect them to abc.com.
Here is my current htaccess file:
<IfModule mod_rewrite.c>
RewriteBase /
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
Normally I know how to do the redirect, but im having issues since it already has those few lines in there.
Add something like this immediately after
RewriteEngine on
:If you want redirect example.com to www.example.com you can try below code
I use the code below. It can be used for any domain name. You just need to enter it in your .htaccess file.
(edited to have all the code in the same block)
There are two methods available
1) use mod_alias apache module
Redirect permanent /something http://yourwebsite.com/something
2) Add the following entry in your .htaccess / http.conf / yourwebsite.conf in the webserver configuarion directory
RewriteEngine on RewriteCond %{HTTP_HOST} ^yourwebsite.com RewriteRule ^(.*)$ http://www.yourwebsite.com$1 [R=permanent,L]