views:

42

answers:

2

I need a .htaccess file: the file will rewrite rule for:

xyz.sitename.com will be rewritten as: sitename.com/index.php/a/b/xyz

xyz.sitename.com/m/n/o will be rewritten as: sitename.com/index.php/m/n/o/xyz

sitename.com/m/n/o will be rewritten as: sitename.com/index.php/m/n/o

A: 
Options +FollowSymlinks
RewriteEngine on
RewriteRule (.+).sitename.com/ sitename.com/index.php/a/b/$1
RewriteRule (.+).sitename.com/(.+) sitename.com/$2/$1

See .htaccess trips and tips.

mcandre
it's not working. please help me again
Mazhar Ahmed
xyz.sitename.com will be rewritten as: sitename.com/index.php/a/b/xyzxyz.sitename.com/m/n/o will be rewritten as: sitename.com/index.php/m/n/o/xyzsitename.com/m/n/o will be rewritten as: sitename.com/index.php/m/n/oplease, solve this, and help me
Mazhar Ahmed
mod_rewrite only works on the path after the domain name http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html - you'd need a lot of RewriteConds to deal with this...
HorusKol
A: 

Try this:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{HTTP_HOST} ^www [OR]
RewriteCond /%{HTTP_HOST} ^(/[^\.]+)\.[^\.]+\.[^\.]+$
RewriteRule ^.*$ /index.php/$0%1

Although, as I've mentioned in another answer, trying to create PATH_INFO with mod_rewrite seems to be a little problematic. You might have better luck, but take the alternatives of writing the path to a query string or using $_SERVER variables to get this information into consideration.

Tim Stone
that's not working, please help me again
Mazhar Ahmed
What happens when it doesn't work?
Tim Stone