具有htaccess重写规则的多个域

时间:2014-04-28 20:22:19

标签: apache .htaccess codeigniter mod-rewrite subdomain

我很难让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,只为特定域运行重写规则 有没有办法在不指定域的情况下解决这个问题?

1 个答案:

答案 0 :(得分:2)

仅使用此行创建/root/staging/StagingWebsite/.htaccess

RewriteEngine on

这将覆盖任何父母的重写规则。

相关问题