1

CI を複数のアプリケーションに分割したくありません。ルート /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 - しかし、index.php を URL から隠したいと思います。したがって、私の .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 があり、そこからワードプレスを実行しますが、CI が実行される /app フォルダーに影響しますか? どうもありがとう!

4

3 に答える 3

3

これを各フォルダーに追加してみてください(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> 
于 2012-06-21T10:06:35.073 に答える
0

RewriteBase ディレクティブを追加すると機能しますか?

RewriteEngine on
RewriteBase /app1/
RewriteCond $1 !^(index\.php|gfx|css|js|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]
于 2012-06-21T10:00:34.250 に答える
0

よし、今は動いている。数時間のデバッグの後。何がうまくいったのか正確にはわかりませんがAllowOverride All、デフォルトの vhost に a が欠けていたと思います。apache の再起動後、すべての /app/app1/ フォルダーでこの htaccess が機能し始めました。

RewriteEngine on

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

私の質問に貢献してくれたすべての人に感謝します。

于 2012-06-21T11:39:32.773 に答える