[英]problem with rewrite url codeigniter PHP htacess
I have problem with rewrite in CodeIgniter. 我在CodeIgniter中重写存在问题。 I'm starting to study CI but the url is bothering me.
我开始学习CI,但网址困扰着我。
http: //localhost/projetoci/index.php/restrict
I already enabled rewrite mode in apache. 我已经在apache中启用了重写模式。
LoadModule rewrite_module modules / mod_rewrite.so
I created the .htaccess file 我创建了.htaccess文件
RewriteEngine on
RewriteCond $ 1! ^ (Index \ .php | resources | robots \ .txt)
RewriteCond% {REQUEST_FILENAME}! -F
RewriteCond% {REQUEST_FILENAME}! -D
RewriteRule ^ (. *) $ Index.php / $ 1 [L, QSA]
but none of this makes removing index.php from url. 但这都无法从网址中删除index.php。 I've looked at other topics and couldn't solve it.
我看过其他主题,无法解决。
In application/config
folder, find and replace the below code in config.php file. 在
application/config
文件夹中,找到并替换以下config.php文件中的代码。
$config['index_page'] = "";
Now set .htaccess file as below. 现在,如下所示设置.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.