1

私はこれに関する投稿を読みましたが、それは私の問題に対する答えを与えませんでした コードイグナイターとSOの質問のフォーラムで見つけたすべてを設定しました

現在、次の設定があります:.htaccessファイル

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    #'system' can be replaced if you have renamed your system folder.
    RewriteCond %{REQUEST_URI} ^system.*
    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

    #This last condition enables access to the images and css folders, and the robots.txt file
    RewriteCond $1 !^(index\.php|(.*)\.swf|images|robots\.txt|css|docs|cache)
    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.
    ErrorDocument 404 /application/errors/404.php
</IfModule>

そして私もセットしました$config['index_page'] = '';

しかし、これは機能しません *http://localhost:8088/crud_demo/index.php/login* と入力しても URL は変更されませんが、*http://localhost:8088/crud_demo/login* と入力すると機能しますNot Foundエラーが表示されます

私のルート設定

$route['register'] = "register";
$route['manage'] = "manage";
$route['default_controller'] = "login";
$route['404_override'] = '';
4

3 に答える 3

1

/etc/apache2/sites-available/000-default.confubuntuの仮想ホスト ファイルで、AllowOverride None を AllowOverride All に変更します。

Windowsの仮想ホスト ファイルで、AllowOverride None を AllowOverride All に変更/etc/apache2/sites-available/default.confします。

<VirtualHost *:80>
    ServerAdmin webmaster@localhost

    DocumentRoot /var/www
    <Directory />
            Options FollowSymLinks
            AllowOverride All    <---- replace None with All
    </Directory>
    <Directory /var/www >
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All   <---  replace None with All
            Order allow,deny
            allow from all
    </Directory>
....

次に、このコードを codeigniter のルート フォルダーにある .htaccess ファイルに配置します。

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

それは間違いなく機能します。

于 2015-05-14T09:34:13.123 に答える
0

RewriteRule ^crud_demo/(.*)$ crud_demo/index.php/$1

http://martinmelin.se/rewrite-rule-tester/で URL の書き換えをテストします。

CodeIgniter には、他の PHP フレームワークと同様に URL をルーティングする独自の方法があると思います。こちらをご覧ください: http://codeigniter.com/user_guide/general/routing.html

于 2012-04-19T05:27:10.933 に答える
0

crud_demo がルートディレクトリのサブフォルダーである場合は、変更する必要があります

RewriteBase /

RewriteBase /crud_demo

于 2012-04-19T05:27:45.050 に答える