操作系统:CentOS 5.3 Apache 2.2.3
假设我在机器上有两个站点(/ var / www / html / site1和/ var / www / html / site2)。 目前,
http://hostname/site1 http://hostname/site2
带到现场。 和http://主机名带到Apache欢迎页面。 有什么办法使( http://主机名 )直接到site1通过只是改变configuration,但不移动文件夹结构? 非常感谢!!
你想要一个Redirect*指令。
我在下面find了答案。
# Turn on rewrites. RewriteEngine on # Only apply to URLs on this domain RewriteCond %{HTTP_HOST} ^192\.168\.1\.100$ (this seems unnecessary) # Only apply to URLs that aren't already under folder. RewriteCond %{REQUEST_URI} !^/site2/ RewriteCond %{REQUEST_URI} !^/site2 # Don't apply to URLs that go to existing files or folders. RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d # Rewrite all those to insert /folder. RewriteRule ^(.*)$ /site2/$1 # Also redirect the root folder. RewriteCond %{HTTP_HOST} ^192\.168\.1\.100$ RewriteRule ^(/)?$ /site2/index.php [L] RewriteCond %{HTTP_HOST} ^myHost\.com$ RewriteRule ^(/)?$ /site2/index.php [L]
所以现在http://192.168.1.100会重写到http://192.168.1.100/site2/不过,我也设置了一个DNS让myHost.comparsing为192.168.1.100。 现在的重写不能用于http://myHost.com任何人都可以帮忙吗? 非常感谢!
编辑:通过添加另一个重写规则刚刚find解决scheme。