簡體   English   中英

重寫URL codeigniter PHP htacess的問題

[英]problem with rewrite url codeigniter PHP htacess

我在CodeIgniter中重寫存在問題。 我開始學習CI,但網址困擾着我。

http: //localhost/projetoci/index.php/restrict

我已經在apache中啟用了重寫模式。

LoadModule rewrite_module modules / mod_rewrite.so

我創建了.htaccess文件

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

但這都無法從網址中刪除index.php。 我看過其他主題,無法解決。

application/config文件夾中,找到並替換以下config.php文件中的代碼。

$config['index_page'] = "";

現在,如下所示設置.htaccess文件。

<IfModule mod_rewrite.c>

    RewriteEngine On

    RewriteBase /projetoci/

    #This bit rewrites your host name to include www    
    #RewriteCond %{HTTP_HOST} !^(www\.|$) [NC]  
    #RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

    #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 ^(.*)$ /projetoci/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 ^(.*)$ /projetoci/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 ^(.*)$ /projetoci/index.php?/$1 [L]

</IfModule>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM