views:

706

answers:

2

I'm trying to rewrite abc.example.com/path to abc.example.com/index.php/abc/path using the following .htaccess:

RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} ^(abc)\.example\.com
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/abc/$1 [L]

The situation is:

domain    www.example.com
vhost     www
subdomain abc.example.com
vhost     abc

I don't want index.php/abc/ to be shown in the URL.

Does anybody have some suggestions?

A: 

With the following code everything you type after the domain will be appended to /index.php/abc

abc.domain.com/URL      -> abc.domain.com/index.php/abc/URL
abc.domain.com/URL/     -> abc.domain.com/index.php/abc/URL/
abc.domain.com/URL/URL  -> abc.domain.com/index.php/abc/URL/URL
abc.domain.com/URL/URL/ -> abc.domain.com/index.php/abc/URL/URL/

Rewrite code:

RewriteCond %{HTTP_HOST} ^(abc).domain.com
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ /index.php/%1$1 [NC,L]
Fabian
Thanks, but no...the situation is:abc.domain.com -> abc.domain.com/index.php/abc ( or www.domain.com/index.php/abc )to be more complete:abc.domain.com/features -> abc.domain.com/index.php/abc/features ( or www.domain.com/index.php/abc/features )andabc.domain.com/features/feature -> abc.domain.com/index.php/abc/features/feature ( or www.domain.com/index.php/abc/features/feature )
Adjusted my answer accordingly
Fabian
A: 

Try this rule in your .htaccess file:

RewriteCond %{HTTP_HOST} ^([^./]+)\.example\.com$
RewriteRule ^index\.php$ index.php/%1%{REQUEST_URI} [L]
Gumbo