0

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

Tim Stone
  • 19,119
  • 6
  • 56
  • 66
Mazhar Ahmed
  • 1,523
  • 2
  • 24
  • 41

2 Answers2

0
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
  • 22,868
  • 20
  • 88
  • 147
  • 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 please, solve this, and help me – Mazhar Ahmed Jul 12 '10 at 18:27
  • 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 Jul 13 '10 at 00:11
0

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.

Community
  • 1
  • 1
Tim Stone
  • 19,119
  • 6
  • 56
  • 66