1

現在、CodeIgniter を学習しようとしています。

これは機能します:

 http://localhost/NewsPage/index.php/news/fenerana

しかし、次の場合に機能させたいです。

http://localhost/NewsPage/news/fenerana

これどうやってするの?私の現在のroutes.phpファイルは次のとおりです。

$route['news/(:any)'] = 'news/view/$1';
$route['news'] = 'news';
$route['(:any)'] = 'pages/view/$1';
$route['default_controller'] = 'pages/view';
4

2 に答える 2

2

最初に application/config/config.php に移動し、'index_page' を空にします:

$config['index_page'] = '';

次に、次のように .htaccess を使用します (CI index.php と同じレベルに配置します)。

DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|images_folder|css_folder_maybe)
RewriteRule ^(.*)$ ./index.php/$1 [L]
于 2013-02-10T18:37:46.980 に答える
1

ドキュメントを見てください:

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

ただし、私の提案は、このバージョンを使用することです。

RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php/$1 [L]
于 2013-02-10T18:37:59.010 に答える