简体   繁体   English

.htaccess在子文件夹中

[英].htaccess in subfolder

The main site runs WordPress with .htaccess 主站点使用.htaccess运行WordPress

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

I'm going to create an CodeIgniter app in subdirectory site.com/online/ If simply add CI .hta file in subfolder it wouldn't work. 我将在子目录site.com/online/创建一个CodeIgniter应用程序。如果只是在子文件夹中添加CI .hta文件,它将无法正常工作。 CI .htaccess: CI .htaccess:

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

Is it possible to combine two .htaccess files or to do something with .htaccess in CI subfolder? 是否可以组合两个.htaccess文件或在CI子文件夹中使用.htaccess执行某些操作? Thank you. 谢谢。

UPD. UPD。 Thank you for answers, I've tried all variants, and eventually moved project to subdomain. 感谢您的回答,我尝试了所有变种,并最终将项目移至子域。

First thing, your .htaccess should be like this: 首先,你的.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]

Then you can remove (or rename) .htaccess in the online subfolder. 然后,您可以在online子文件夹中删除(或重命名).htaccess。

Try this for the codeigniter .htaccess: 尝试使用codeigniter .htaccess:

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

Otherwise all requests to that subfolder would be redirected down to wordpress. 否则,对该子文件夹的所有请求都将被重定向到wordpress。

Are you setting AllowOverride ? 你在设置AllowOverride吗? According to the docs you need to allow FileInfo overrides for mod_rewrite. 根据文档,您需要允许FileInfo覆盖mod_rewrite。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM