1

According to me client demand, he want to use only http://example.com urls in his codeinigter. in other words he want to fully ignore www from urls path. please somebody let me know, how i can set these setting in codeigniter?

$config['base_url'] = 'http://example.com';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
$config['url_suffix'] = '';

i set this type url in config.php, but still www urls works.

Ravi Dhoriya ツ
  • 4,435
  • 8
  • 37
  • 48
Ahmed iqbal
  • 597
  • 1
  • 8
  • 26
  • Fully ignore means that `http://www.example.com` should not deliver the site? Can't you just remove the subdomain from the web server settings, or even the DNS server? There's nothing magical in the `www` prefix: you need to explicitly configure it in order to work. – Álvaro González Apr 21 '14 at 10:30
  • possible duplicate of [Generic htaccess redirect www to non-www](http://stackoverflow.com/questions/234723/generic-htaccess-redirect-www-to-non-www) – Álvaro González Apr 21 '14 at 11:29
  • Am I doing something wrong when I ask for clarifications like, don't know, inadvertently using offensive words because I'm not a native speaker or something like that? – Álvaro González Apr 21 '14 at 11:30

1 Answers1

3

Try this, in your .htaccess

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

It will redirect all www url requests to non-www url.

e.g http://www.yoursite/index.php/hello/world?p=123

to http://yoursite/index.php/hello/world?p=123

Ravi Dhoriya ツ
  • 4,435
  • 8
  • 37
  • 48