Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在没有index.php的情况下,codeigniter重定向无法工作?_Codeigniter_Codeigniter 2_Codeigniter Url_Codeigniter Routing_Codeigniter 3 - Fatal编程技术网

在没有index.php的情况下,codeigniter重定向无法工作?

在没有index.php的情况下,codeigniter重定向无法工作?,codeigniter,codeigniter-2,codeigniter-url,codeigniter-routing,codeigniter-3,Codeigniter,Codeigniter 2,Codeigniter Url,Codeigniter Routing,Codeigniter 3,我是codeigniter的新手,重定向页面索引时。默认情况下,php不会加载,因此我在htaccess文件中尝试了以下代码。我已经安装了PHP5.3.10、apache服务器和postgres数据库。因此,如果除了更改.htaccess和httpd.conf之外还需要进行任何新的配置,请告诉我。我已经看到以前就同一问题提出的问题,我引用了这些问题的所有内容,但我仍然无法解决这个问题。请让我知道还有什么额外的事情要做 .htaccess文件 <IfModule mod_rewrite.c

我是codeigniter的新手,重定向页面索引时。默认情况下,php不会加载,因此我在htaccess文件中尝试了以下代码。我已经安装了PHP5.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] 
RewriteEngine On#检查用户是否试图访问有效的文件,如图像或css文档,如果这不是真的,它会将#请求发送到index.php RewriteCond%{request_FILENAME}-f RewriteCond%{REQUEST_FILENAME}-d#最后一个条件允许访问图像和css文件夹,以及robots.txt文件RewriteCond$1^(index\.php | public | images | robots\.txt | css)RewriteRule^(.*)$index.php/$1[L]
RewriteCond%{REQUEST_FILENAME}上的RewriteEngine-f RewriteCond%{REQUEST_FILENAME}-d重写秒1美元^/(index\.php | assets/| humans\.txt)重写规则^(.*)$index.php/$1[L]
重新启动发动机
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则。*index.php/$0[PT,L]
httpd.conf文件 服务器名本地主机

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

选项如下符号链接
允许超越所有
命令拒绝,允许
全盘否定

将其粘贴到.htaccess文件中

RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

为了避免url中的index.php,您应该做以下事情

  • 始终确保您拥有.htaccess文件。你已经有了

  • 在上面@charlie建议的.htaccess中包含内容

  • 使用nano命令编辑httpd.conf文件,并包括main thing keep allowveride All

  • 首先禁用重写模式并再次启用,然后使用以下命令重新启动apache2服务器

    sudo a2dismod rewrite//禁用重写模式

     <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] 
    
    sudo a2enmod rewrite//启用重写模式

     <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] 
    
    sudo服务apache2 restart//它重新启动您的apache

  •  <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] 
    

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

如果启用了重写模块,这可能会有所帮助?请确保
$config['index\u page']=''
application/config/config.php
check file permission sudo chmod 777-R projectDirectory/@Pooshonk先生,我已经查看了该链接我已经尝试了那些代码,但它仍然不起作用。@Charle先生,我已经尝试了这段代码它不起作用