繁体   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