Reputation: 24828
So I have mydomain.tld
, www.mydomain.tld
and res.mydomain.tld
all pointing to the same directory: /var/www/mydomain
. In that directory, there's my codeigniter application.
So what I'm trying to do is to forward all requests made through res.mydomain.tld
to a specific controller called resources
.
What I have:
RewriteCond %{HTTP_HOST} ^res\.mydomain\.tld$
RewriteRule ^(.*)$ /index.php?/resources/$1 [L]
This produces a server error, my rewrite log doesn't provide any clues about why; it just shows some very weird logic being applied to the request string.
Any idea of why this isn't working?
Upvotes: 2
Views: 337
Reputation: 2247
Leave your .htaccess was before.
In your routes.php
if($_SERVER["SERVER_NAME"]=="res.mydomain.tld"){
$route['default_controller'] = "resources";
}else{
//$route['default_controller'] = Your default controller...
}
Upvotes: 4
Reputation: 16825
You created a infinite loop. It keeps on rewriting, because the rules always match, and match again. Just add a rule like the following above your rule
RewriteRule ^index.php - [L]
This will prevent any remaining rules underneath it from executing if the (already rewritten) url starts with index.php
Upvotes: 3
Reputation: 270637
Make sure that index.php
isn't matching and going into a rewrite loop:
RewriteCond %{REQUEST_URI} !^index\.php
RewriteCond %{HTTP_HOST} ^res\.mydomain\.tld$
RewriteRule ^(.*)$ /index.php?/resources/$1 [L]
Upvotes: 2