首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >具有停放/重定向域的CodeIgniter的Htaccess CodeIgniter

具有停放/重定向域的CodeIgniter的Htaccess CodeIgniter
EN

Stack Overflow用户
提问于 2010-10-06 15:10:52
回答 1查看 411关注 0票数 0

我有这样的情况:

位于maindomain.com

  • othersite.com的
  • 主机被停放到maindomain.com
  • htaccess是用来将对othersite.com的所有请求重定向到一个子文件夹: /site-othersite/
  • I想在othersite.com上使用CodeIgniter,但是othersite.com中有一些目录和文件我不希望CodeIgniter redirection.
  • home.php是my CodeIgniter的主页。

我尝试将我经常使用的ModRewrite与我在CodeIgniter wiki中找到的内容结合起来,但是我遇到了麻烦。

示例:我不希望CodeIgniter处理othersite.com/demo/或thersite.com/robots.txt。我有这个:

代码语言:javascript
复制
# 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安装,一切都很好。除了试图让演示/和robots.txt成为CodeIgniter的“外部”之外,这是行不通的。

ModRewrite大师们有什么建议吗?谢谢!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2010-10-06 16:00:26

弄明白了。它需要通过两条规则来处理:

代码语言:javascript
复制
# Redirect various urls to subfolders of the format: /site-thename/

RewriteEngine On

# Handle pages and directories that should not go through CodeIgniter.
RewriteCond %{HTTP_HOST} ^(www\.)?othersite\.com
RewriteCond %{REQUEST_URI} !^/site-othersite/
RewriteCond %{REQUEST_URI} ^/demo/ [OR]
RewriteCond %{REQUEST_URI} ^/robots.txt

Rewriterule ^(.*)$ /site-othersite/$1 [L]


# Handle CodeIgniter URLs.
RewriteCond %{HTTP_HOST} ^(www\.)?othersite\.com
RewriteCond %{REQUEST_URI} !^/site-othersite/

Rewriterule ^(.*)$ /site-othersite/home.php?/$1 [L]
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/3873993

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档