CodeIgniter使用.htaccess文件删除index.php

编程入门 行业动态 更新时间:2024-10-22 11:09:21
本文介绍了CodeIgniter使用.htaccess文件删除index.php的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

使用.htaccess文件在CodeIgniter中删除index.php对我不起作用。我尝试下面的代码eventhough不工作。

< IfModule mod_rewrite.c& RewriteEngine on RewriteBase / RewriteCond $ 1!^(index\.php | resources | robots\.txt) RewriteCond%{REQUEST_FILENAME}!-f RewriteCond%{REQUEST_FILENAME}!-d RewriteRule ^(。*)$ /index.php?/$1 [L,QSA] < / IfModule>

我试过这个 firstcode.info/codeigniter-removing-index-php-from-url/ 。但不工作。但它的工作在我的本地主机。我也编辑了httpd.config文件。但关闭不使用。 请帮助我。

解决方案

STEP 1

打开文件夹application / config,然后打开文件config.php。找到并替换 config.php文件中的以下代码。

em>

$ config ['index_page'] =index.php 以下代码 $ config ['index_page'] =

STEP 2

p $ p> < IfModule mod_rewrite.c> RewriteEngine on RewriteCond%{REQUEST_FILENAME}!-f RewriteCond%{REQUEST_FILENAME}!-d RewriteRule ^(。*)$ index.php / $ 1 [L,QSA] < / IfModule>

b $ b

STEP 3

application / config / config.php,,然后查找并替换以下代码

p $ p> $ config ['uri_protocol'] =AUTO 替换以下代码 $ config ['uri_protocol'] = REQUEST_URI

Removing index.php in CodeIgniter using .htaccess file is not working for me. I Tried following code eventhough not working.

<IfModule mod_rewrite.c> RewriteEngine on RewriteBase / RewriteCond $1 !^(index\.php|resources|robots\.txt) RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /index.php?/$1 [L,QSA] </IfModule>

I tried this firstcode.info/codeigniter-removing-index-php-from-url/. But not working.But its working in my localhost. I also edited httpd.config file.But off no use. Please help me.

解决方案

STEP 1

Open the folder "application/config" and open the file "config.php". find and replace the below code in config.php file.

find the below code

$config['index_page'] = "index.php" replace with the below code $config['index_page'] = "

STEP 2

Write below code in .htaccess file

<IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [L,QSA] </IfModule>

STEP 3

"application/config/config.php", then find and replace the below code

find the below code

$config['uri_protocol'] = "AUTO" replace with the below code $config['uri_protocol'] = "REQUEST_URI"

更多推荐

CodeIgniter使用.htaccess文件删除index.php

本文发布于:2023-10-31 18:52:45,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文件   htaccess   CodeIgniter   index   php

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!