解決codeigniter偽靜態(tài)失效

字號:


    原來地址:http://127.0.0.1/onsite/index.php/welcome/index/abc123
    修改后地址:http://127.0.0.1/onsite/abc123.html
    代碼如下:
    <ifmodule mod_rewrite.c>
    rewriteengine on
    rewritebase /onsite
    rewritecond %{request_uri} ^system.*
    rewriterule ^(.*)$ /index.php?/$1 [l]
    rewritecond %{request_uri} ^application.*
    rewriterule ^(.*)$ /index.php?/$1 [l]
    rewritecond %{request_filename} !-f
    rewritecond %{request_filename} !-d
    rewriterule ^(.*)\.html$ index.php/welcome/index/$1 [l]
    </ifmodule>
    規(guī)則是沒有錯的,但萬想不到codeigniter竟然報404找不到頁面;經(jīng)過測試在根目錄建立同名的html文件是能夠正常顯示的;
    那問題應該是ci的配置導致的;經(jīng)過一番波折,發(fā)現(xiàn)一個參數(shù):
    代碼如下:
    $config['uri_protocol'] = 'auto';
    把它改成:
    代碼如下:
    $config['uri_protocol'] = 'path_info';
    頁面終于顯示正常了;