0

私は自分のcodeigniterコードをWebルートに持っています。mod_rewriteが有効になっています。phpinfo.phpで確認しました。これで、コード構造は次のようになります。

  controllers/home.php(default controller)
  controllers/products.php (not listed in routes.php under config)
  and then a subfolder
  controllers/members/login.php

私が試しているURLは

 domain_name/ ---------> works

(注:これは、$ config ['index.php'] =''であるため、echo base_urlが私を指していると思いますが、index.phpに設定しても、作業中のindex.php urlを指していません)

  domain_name/products ------> doesn't work
    domain_name/index.php/products ------> works
    similarly 
    domain_name/members ----->doesn't work
    domain_name/index.php/members --->work

これはindex.phpで機能しているので、routes.phpは正常に機能していると思います。しかし、echo $ base_urlが、index.phpurlなしでこれらを指し示しているのです。

私は/var/www/である私のウェブルートにある.htacessファイルを試しましたcodeigniterのバージョンは2.1.3です

助けてください。私はこれがindex.phpの有無にかかわらず機能することを望んでおり、私が欠けているものを説明できる場合は、説明をお願いします。

4

1 に答える 1

1

一般に、Codeigniter は、メイン ルートを呼び出すときに index.php を明示的に非表示にする傾向がありますが、URL で直接サブフォルダーにアクセスしようとすると、index.php が必要になります。そのためには、.htaccess を内部に含める必要があります。 domain/product または domain/index.php/product の使用を受け入れる ci ファイルシステム

したがって、この .htacess を含めて、その書き換えベースを ci フォルダー名に変更してみてください

 <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /cifolder

    #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>  
于 2013-03-22T01:42:18.193 に答える