【发布时间】:2010-10-07 00:00:26
【问题描述】:
我有这种情况:
- 主机位于 maindomain.com
- othersite.com 停放在 maindomain.com 上
- htaccess 用于将所有对 othersite.com 的请求重定向到子文件夹:/site-othersite/
- 我想在 othersite.com 上使用 CodeIgniter,但在 othersite.com 中有一些目录和文件我不想让 CodeIgniter 重定向。
- home.php 是我的 CodeIgniter 主页。
我尝试将我用于停放域的常用 ModRewrite 与我在 CodeIgniter wiki 中找到的内容结合起来,但遇到了问题。
示例: 我不希望 CodeIgniter 处理 othersite.com/demo/ 或 othersite.com/robots.txt。我有这个:
# Redirect various urls to subfolders of the format: /site-thename/
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?othersite\.com
RewriteCond %{REQUEST_URI} !^/site-othersite/
RewriteCond %{REQUEST_URI} !^/demo/
RewriteCond %{REQUEST_URI} !^robots\.txt
Rewriterule ^(.*)$ /site-othersite/home.php?/$1 [L]
CodeIgniter 安装一切正常。除了试图让 demo/ 和 robots.txt 成为 CodeIgniter 的“外部”之外是行不通的。
ModRewrite 大师们有什么建议吗?谢谢!
【问题讨论】:
-
我想我的困惑喜欢理解 RewriteCond 行是如何工作的。是否所有这些都必须为真才能执行规则?另外,我如何格式化异常(最后两个条件)。第二个条件是防止重定向循环所必需的。