• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Force www?

This is probably a silly question, but how do I force codeigniter to make sure the "www" subdomain is present in the url string? For example, if the user types "mydomain.com", I want that to resolve as "www.mydomain.com". ... I'm using ajax via jquery and apparently the subdomain has to match exactly in order for it to work.

Is this something that's done on the CI level, or do I have to use .htaccess or something?

.htaccess tips and tricks


:question: :exclaim:

you can use .htaccess. to solve it

[url="http://www.parscanada.com"]مهاجرت به کانادا[/url]

And to actually be complete in response, here's what solved it:

Below is the root .htaccess file, and I have the base_url set to "http://www.mydomain.com/" in my CI config.

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

RewriteCond $1 !^(index\.php|images|css|js|robots\.txt)
RewriteRule ^(.*)$ /index.php?/$1 [L]

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.