My url is http://mydomain.com/controllername/method/ .
Now I need the site url like.
http://mydomain.com/method.
mydomain name wants to access as a controller name .
for example. url like
www.testing.com/pages. 'testing' act as a controller in codeigniter.
Explain how to get the controller name from the domain name. and also how to remove the controller name(www.mydomain.com/controllername/method) from the url.
I need the url like www.controllername.com/method
In application/config/routes.php use this code
$route['method'] = 'controllername/method';
for routing.
Use Routes. Routes in codeigniter
You have to define routes in
application/config/routes.php.
http://ellislab.com/codeigniter/user-guide/general/routing.html
This may help.
IMO this would best be done with your .htaccess file instead of CI routes. I am not the best with these rules, so typo may exist, this is the general idea:
// If HOST contains www, strip www.
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [L,R=301]
// If URI contains DOMAIN.COM, it was probably just redirected, dont do it again!
RewriteCond %{REQUEST_URI} !^%{HTTP_HOST}
// Re-write http://domain.com/method to http://domain.com/domain.com/method
RewriteRule (.*) http://%{HTTP_HOST}/%{HTTP_HOST}/$1 [L]