【问题标题】:404 - File or directory not found. The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable404 - 找不到文件或目录。您正在查找的资源可能已被删除、名称已更改或暂时不可用
【发布时间】:2017-10-17 20:30:56
【问题描述】:

我已经开发了一个关于 codeigniter 一个 php 框架的项目。它在我运行 xampp 的本地主机上运行良好。我已经将我的整个项目上传到“wwwroot”文件夹中,我只能得到我的打开页面。但是当我尝试点击我得到的任何链接时:

HTTP 错误 404.0 - 未找到您要查找的资源已被删除、更改名称或暂时不可用..

这是我的网站链接: 链接:http://www.iimkondigre.in/ 问题链接:http://www.iimkondigre.in/course_archive

是我的 .htaccess 文件:


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

【问题讨论】:

标签: php codeigniter


【解决方案1】:

试试看。

打开 config.php 并进行以下替换

$config['index_page'] = "index.php"
to
$config['index_page'] = ""

在某些情况下,uri_protocol 的默认设置无法正常工作。 只需替换

$config['uri_protocol'] ="AUTO"

by

$config['uri_protocol'] = "REQUEST_URI"

.HTACCESS

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

对于 Windows 服务器
Web.config 文件

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="MyRule"> 
                    <match url="^(.*)$" /> 
                    <conditions> 
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> 
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> 
                    </conditions> 
                    <action type="Rewrite" url="index.php/{R:1}" appendQueryString="false" /> 
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration> 

【讨论】:

  • 我在config.php中的base_url对吗??? $config['base_url'] = 'iimkondigre.in';
  • 我有一个问题是他们的这个错误取决于像 Linux 和 Windows 这样的托管操作系统吗?在一个项目中,我将使用 codeignietr 并使用 linux 服务器,它们都可以正常工作,我认为现在这个项目我使用的是 windows,所以是错误的吗?
  • 不,这个问题与.htaccess url重写有关。
  • 那我该怎么办??请
  • 我提供所有静态页面链接,例如“iimkondigre.in/index.php/course_archive”,并且运行良好。但他们是动态页面的问题,如联系我们页面
【解决方案2】:

到目前为止我遇到的唯一解决方案是替换

<a href="<?php echo base_url("abc"); ?>">click here</a>

<a href="<?php echo site_url("abc"); ?>">click here</a>

【讨论】:

  • 行不通,它们是我们需要设置 site_url() 的任何文件吗??
【解决方案3】:

正如上面回答的提到...... 只需将“.htaccess”代码更改如下

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

并创建一个名为“web.config”的文件并将其保存在根目录中,这些是 Windows 服务器设置。

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="MyRule"> 
                    <match url="^(.*)$" /> 
                    <conditions> 
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> 
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> 
                    </conditions> 
                    <action type="Rewrite" url="index.php/{R:1}" appendQueryString="false" /> 
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

【讨论】:

    猜你喜欢
    • 2018-01-05
    • 2020-07-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-27
    • 1970-01-01
    • 2020-04-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多