加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

在没有index.php的情况下,codeigniter重定向不起作用?

发布时间:2020-12-13 16:54:23 所属栏目:PHP教程 来源:网络整理
导读:我是codeigniter的新手,同时重定向页面index.php默认没有加载,所以我在htaccess文件中尝试了下面的代码.我已经安装了php 5.3.10,apache服务器和postgres数据库.所以如果除了更改.htaccess和httpd.conf之外还要进行任何新的配置,请告诉我.我已经看到以前在同
我是codeigniter的新手,同时重定向页面index.php默认没有加载,所以我在htaccess文件中尝试了下面的代码.我已经安装了php 5.3.10,apache服务器和postgres数据库.所以如果除了更改.htaccess和httpd.conf之外还要进行任何新的配置,请告诉我.我已经看到以前在同一问题上提出的问题,我从这些问题中提到了一切,但我仍然无法解决这个问题.请让我知道还有什么要做的事情.

.htaccess文件

<IfModule mod_rewrite.c> RewriteEngine On #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 #This last condition enables access to the images and css folders,and the robots.txt file RewriteCond $1 !^(index.php|public|images|robots.txt|css) RewriteRule ^(.*)$index.php/$1 [L] </IfModule>
    RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond $1 !^/(index.php|assets/|humans.txt) RewriteRule ^(.*)$index.php/$1 [L]
    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule .* index.php/$0 [PT,L]

httpd.conf文件
????ServerName localhost

<Directory />
   Options FollowSymLinks
   AllowOverride All
   Order deny,allow
   Deny from all
</Directory>

解决方法

你应该做些什么来避免在url中使用index.php

>始终确保您拥有.htaccess文件.你已经.
>在.htaccess中包含@charlie上面建议的内容.
>使用nano命令编辑httpd.conf文件并包含main thing keepoveroveride All
>首先禁用重写模式并再次启用它,然后使用以下命令重启apache2服务器.

sudo a2dismod rewrite //禁用重写模式

sudo a2enmod rewrite //启用重写模式

sudo service apache2 restart //重新启动你的apache

这就是你需要做的一切.祝一切顺利.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读