【发布时间】:2014-06-14 13:19:38
【问题描述】:
我无法让 htaccess 与子域一起工作。
我的服务器结构:
root / index.php ---//codeigniter 索引文件,对于应用程序 A,主域指向此处。root/staging/StagingWebsite ---// 我的子域指向此处。
StagingWebsite 文件夹有一个名为 temp.html
的文件
继续前进,我的根 htaccess 文件是这样的:
RewriteEngine on
RewriteCond
RewriteCond $1 ^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php?/$1 [L]
这会将对 MyDomain/foo 的任何访问权限转换为 MyDomain/index.php/foo。 (不显示 index.php)。
问题:
当我尝试访问我的subdomain/temp.html 时,我得到一个500 internal error。
当我删除我的root/.htaccess 时,它工作正常。所以这显然是我的 htaccess 文件。
我发现问题是 root/.htaccess 规则被应用于子域,这破坏了一切,但我不知道如何解决。
我在root/staging/StagingWebsite 中放置了一个空的.htaccess 文件,希望它会覆盖之前的任何htaccess 设置,但这不起作用。
编辑
我专门解决了这个问题,但我不喜欢这个解决方案。
我添加了一个 RewriteCond 以仅针对特定域运行重写规则。
有没有办法在不指定域的情况下解决这个问题?
【问题讨论】:
标签: apache .htaccess codeigniter mod-rewrite subdomain