Ahmed iqbal
Ahmed iqbal

Reputation: 597

how to remove www path in Codeigniter settings

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.

Upvotes: 1

Views: 157

Answers (1)

Ravi Dhoriya ツ
Ravi Dhoriya ツ

Reputation: 4414

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

Upvotes: 3

Related Questions