0

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 ?

0

1 Answer 1

2

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]
Sign up to request clarification or add additional context in comments.

14 Comments

I think its taken as another website as its giving me this error when i types 'shops.annsenglishmediumschool.com' :"Sorry, the website shops.annsenglishmediumschool.com cannot be found"
Did you set up the subdomain? Search for "setting up a subdomain" in your cpanel or on google. Also, check this out
So is it needed to set up subdomains manually in cpanel ? Not work with .htaccess (when enter site as "subdomain.domain.com" )? i am in codeigniter ,so i dont know how its effective in setting up subdomains in cpanel
.htaccess works with apache -- the webserver -- it has nothing to do with CodeIgniter (although you can use both together). If you set up htaccess to redirect or point to a subdomain, the subdomain has to exist on the webserver for it to work. You set up the subdomain through your webserver/webhost; in your case you can use cpanel: docs.cpanel.net/twiki/bin/view/AllDocumentation/CpanelDocs/…
Right. You will need to add an entry to your DNS configuration for the domain. Can do a CNAME or A *.domain.com to point everything at your server. Then htaccess will point it to the shops controller.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.