0

私は多くの記事を見て、さまざまな方法を試しましたが、それでもうまくいきません。

これで、私の URL は のようになりますmysite.com/index.php/[controller]。目標はmysite.com/[controller]

config.phpで:

$config['index_page'] = ""; 
$config['uri_protocol'] = 'REQUEST_URI';

私の.htaccessファイルには

RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

また、Apache サーバーでmod_rewriteが有効になっています。

他の解決策はありますか?

4

5 に答える 5

1

application/config/config.php

$config['base_url'] = '';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';

in .htaccess(アプリケーションフォルダの外に置く)

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

2018-02-27 更新

$config['base_url'] = 'https://stackoverflow.com/'; # Must fill

そうしないと、localhost の代わりに Codeigniter echoing [::1] というエラーが表示されます

これを使って.htaccess

RewriteEngine on
RewriteCond $1 !^(index\.php|assets|image|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]

参照

于 2015-08-03T10:54:41.763 に答える