繁体   English   中英

CodeIgniter多个应用程序htaccess

[英]CodeIgniter multiple applications htaccess

我不想把CI分成多个应用程序。 我应该说它位于root / var / www / app /上名为app的文件夹中。 首先我尝试了这个设置:

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

但我无法正确指出我的htaccess。 所以我继续这样做:

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

现在它可以正常使用url:mysite.com/app/app1/index.php/welcome - 但我想隐藏URL中的index.php。 因此我的.htaccess看起来像这样:

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

但是它没有用,我试图访问mysite.com/app/app1/welcome时得到404。 有人可以澄清我的.htaccess错误吗? 我在根上有另一个.htaccess,并且会从那里运行一些wordpress,但它会影响我运行CI的/ app文件夹吗? 非常感谢!

尝试在每个文件夹上添加此文件夹(来自http://codeigniter.com/wiki/mod_rewrite ):

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    #Removes access to the system folder by users.
    #Additionally this will allow you to create a System.php controller,
    #previously this would not have been possible.
    #'system' can be replaced if you have renamed your system folder.
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    #When your application folder isn't in the system folder
    #This snippet prevents user access to the application folder
    #Submitted by: Fabdrol
    #Rename 'application' to your applications folder name.
    RewriteCond %{REQUEST_URI} ^application.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    #Checks to see if the user is attempting to access a valid file,
    #such as an image or css document, if this isn't true it sends the
    #request to index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
    # If we don't have mod_rewrite installed, all 404's
    # can be sent to index.php, and everything works as normal.
    # Submitted by: ElliotHaughin

    ErrorDocument 404 /index.php
</IfModule> 

添加RewriteBase指令后它是否有效?

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

好吧,现在它正在运作。 经过几个小时的调试。 我不确定究竟是什么诀窍,但我认为我在默认的vhost中缺少AllowOverride All apache重新启动后,每个/ app / app1 /文件夹中的htaccess都开始工作:

RewriteEngine on

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

感谢所有为我的问题做出贡献的人。

暂无
暂无

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

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