codeIgniter多个应用程序的htaccess多个、应用程序、codeIgniter、htaccess

2023-09-02 01:08:50 作者:七遣

我wan't分我的CI到多个应用程序。我应该说,这是在根/无功/网络/应用程序/文件夹名为app。首先,我尝试这样设置:

I wan't to divide my CI into multiple applications. I should say that it is within a folder called app on the root /var/www/app/. First I tried this setup:

/system/
/application/
  /app1/
  /app2/
app1.php
app2.php
.htaccess

但我不能让我的htaccess的正确指向。因此,我继续用这样的:

But I couldn't get my htaccess to point correctly. Therefore I went ahead with this:

/system/
/app1/
  .htaccess
  /application/
  index.php
/app2/
  .htaccess
  /application/
  index.php

而现在它工作正常的网址:mysite.com/app/app1/index.php/welcome - 但我想隐藏的URL的index.php。因此,我的.htaccess看起来是这样的:

And now it works fine with urls: mysite.com/app/app1/index.php/welcome - but I would like to hide index.php from the URL. Therefore my .htaccess looks like this:

RewriteEngine on
RewriteCond $1 !^(index.php|gfx|css|js|robots.txt)
RewriteRule ^(.*)$ index.php/$1 [L]

但它不工作,我试图访问mysite.com/app/app1/welcome时得到404。 可能有人澄清什么是错我的.htaccess?我在根另一个的.htaccess和运行从那里有些字preSS,但会影响我的/ app文件夹CI运行在哪里? 太谢谢你了!

However it is not working, I get 404 when trying to access mysite.com/app/app1/welcome. Could someone clarify whats wrong with my .htaccess? I have another .htaccess on the root and will run some wordpress from there, but would it affect my /app folder where CI runs? Thank you so much!

推荐答案

好了,所以它现在的工作。几个小时的调试后。我不知道到底是什么做的伎俩,但我觉得我是缺少一个的AllowOverride全部在我的默认虚拟主机。阿帕奇重启,这htaccess的每/ APP / APP1 /文件夹,并开始工作后:

Alright so it's working now. After some hours of debugging. I'm not sure exactly what did the trick, but I think I was missing a AllowOverride All in my default vhost. After apache restart and this htaccess in every /app/app1/ folder it started working:

RewriteEngine on

RewriteCond $1 !^(index.php|gfx|css|app|js|robots.txt)
RewriteRule ^(.*)$ index.php/$1 [L]

感谢大家谁促成了我的问题。

Thanks to everyone who contributed to my question.