KTM
KTM

Reputation: 868

htaccess redirection not working in codeigniter

I have my .htaccess code as follows :

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /annsenglishmediumschool
    RewriteCond %{HTTP_HOST} ^(.+?)\.annsenglishmediumschool\.com$
    RewriteRule .* http://annsenglishmediumschool.com/index.php/%1 [L]
</IfModule>

What i need is when user types as (anystring).mysite.com should go to mysite.com/mycontroller/myaction/(anystring),to catch anystring in mycontroller. The problem is that it now takes www to the right as when i types www.annsenglishmediumschool.com it goes to annsenglishmediumschool.com/index.php/www ,

How to resolve this ? Thanks.

EDIT : My cpanel redirects shows as follows :

    Domain:(.+?).annsenglishmediumschool.com
    Directory: /.* 
    Redirect Url :http://annsenglishmediumschool.com/index.php/%1

Any wrong with this ?

Upvotes: 0

Views: 356

Answers (1)

stormdrain
stormdrain

Reputation: 7895

Just add a check to make sure it doesn't start with www

RewriteCond %{REQUEST_URI} ^(.+?)\.annsenglishmediumschool\.com$
RewriteCond %{REQUEST_URI} !^www
RewriteRule .* http://annsenglishmediumschool.com/index.php/%1 [L]

Upvotes: 2

Related Questions