I need a .htaccess file: the file will rewrite rule for:
x开发者_Python百科yz.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
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.
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.
精彩评论