主站点使用 .htaccess 运行 WordPress
<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 做些什么? 谢谢。
更新。 感谢您的回答,我已经尝试了所有变体,并最终将项目移至子域。
最佳答案
首先,您的 .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]
然后您可以删除(或重命名)online
子文件夹中的 .htaccess。
关于php - 子文件夹中的 .htaccess,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5968573/