2011-05-11 65 views
3

主要站点运行WordPress的.htaccess的的.htaccess中的子文件夹

<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase/
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . /index.php [L] 
</IfModule> 

我要去子目录site.com/online/ 创建的CodeIgniter应用如果只是在子文件夹中是行不通增加CI名.hta文件。 CI .htaccess:

RewriteEngine on 
RewriteCond $1 !^(index\.php|robots\.txt|img|styles|js) 
RewriteRule ^(.*)$ /index.php?/$1 [L] 

是否可以合并两个.htaccess文件或在CI子文件夹中使用.htaccess执行某些操作? 谢谢。

UPD。 谢谢你的答案,我已经尝试过所有的变种,并最终将项目移至子域。

回答

1

试试这个为笨的.htaccess:

RewriteEngine on 
RewriteBase /online 
RewriteCond $1 !^(index\.php|robots\.txt|img|styles|js) 
RewriteRule ^(.*)$ /index.php?/$1 [L] 

否则所有该子文件夹的请求将被重定向到WordPress的。

3

的第一件事情,你的.htaccess应该是这样的:

<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase/
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{THE_REQUEST} !^GET\s/+online/ [NC] 
RewriteRule . /index.php [L] 
</IfModule> 

#Then add this for CI handling in the same .htaccess 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond $1 !index\.php [NC] 
RewriteRule ^online/(.*)$ online/index.php?/$1 [L,NC] 

然后你就可以删除(或重命名)的.htaccess在online子文件夹。

+0

谢谢你的回答。当我加入这个,布劳尔返回到404,如果类型/在线/首页/ – Tuco 2011-05-12 01:27:28

+0

如果'在线/首页/'是一个有效的目录名和你希望它是为'在线/的index.php?/ online'那么上述规则办理需要通过移除条件'RewriteCond%{REQUEST_FILENAME}!-d'来放松。现在试试,我编辑了我的答案。 – anubhava 2011-05-12 02:53:46

+0

嗨。浏览器再次重定向到未找到 – Tuco 2011-05-12 05:29:59