![]() |
Force www. included in URL - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Force www. included in URL (/showthread.php?tid=7131) |
Force www. included in URL - El Forum - 03-26-2008 [eluser]iive[/eluser] Hi, I would like to make sure all request to my site is in www.mysite.com instead of mysite.com. I do not know how to configure my .htaccess file to do that. I have googled it a bit and I got a solution for that.. but it doesn't work properly if I combined it with my current .htacess file which hide the index.php from the URL. .htaccess that force www in the url Code: RewriteCond %{HTTP_HOST} !^www.mysite.com$ .htaccess that hide index.php from url Code: <IfModule mod_rewrite.c> Force www. included in URL - El Forum - 03-26-2008 [eluser]gon[/eluser] To hide index.php from url, you can do what is said in the docs: http://ellislab.com/codeigniter/user-guide/general/urls.html Force www. included in URL - El Forum - 03-26-2008 [eluser]johnwbaxter[/eluser] This is mine which does just that. I wont pretend to know what any of it means but it does work! RewriteBase / RewriteCond %{HTTP_HOST} !^www\.mysite\.co.uk$ [NC] RewriteRule ^(.*)$ http://www.mysite.co.uk/$1 [R=301,L] Hope it works for you! Force www. included in URL - El Forum - 03-26-2008 [eluser]iive[/eluser] After I searched around,this is solution that I found which hide index.php from url and append www. for every request to the server. I hope it helps someone who want to have both features. Code: <IfModule mod_rewrite.c> It is not written by me, I just combine these codes together here. |