Codeigniter在本地服务器上运行正常但在Web服务器上运行良好。
我使用XAMPP
进行本地开发。
我正在使用Parallels Plesk Panel 11.0.9 for Microsoft Windows。
未加载codeigniter的404错误页面。 Url是服务器的loadind 404错误页面。我删除了根目录的所有 .htacces
重写规则,并且已包含 index.php
。 仍然无效。
搜索了很多但找不到合适的解决方案
codeigniter文件夹的目录(站点,应用程序,系统)
是
mysite/httpdocs/demo/test/
mysite / httpdocs / demo / test / application / config / config.php
中的基本网址$config['base_url'] = 'http://mysite/httpdocs/demo/test/site/';
在 mysite / httpdocs / demo / test / application / .htaccess
Deny from all
在index.php中设置的集合( mysite / httpdocs / demo / test / site / index.php )
switch (dirname(__FILE__)) {
case 'http://mysite/httpdocs/demo/test/site':
define('ENVIRONMENT', 'development');
break;
default:
define('ENVIRONMENT', 'production');
break;
}
$system_path = '../system';
$application_folder = '../application';
在 mysite / httpdocs / demo / test / site / .htaccess
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
在 mysite / httpdocs / demo / test / application / config / routes.php
$route['default_controller'] = "page";
$route['404_override'] = 'page';
$route['article/(:num)/(:any)'] = 'article/index/$1/$2';
我正在给网址 mysite / demo / test / site 和 它给出了web服务器的404错误页面而不是codeigniter
我在哪里错了?
答案 0 :(得分:11)
我联系了我的主人。他们说php处理程序有问题。
除此之外,IIS不读取.htaccess
文件,而是创建文件web.config
并替换为 mysite / httpdocs / demo / test / site /中的.htaccess
web.config
文件的内容是
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<httpErrors errorMode="Detailed" />
<asp scriptErrorSentToBrowser="true"/>
<rewrite>
<rules>
<rule name="RuleRemoveIndex" stopProcessing="true">
<match url="^(.*)$" ignoreCase="false" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
</conditions>
<action type="Rewrite" url="index.php/{R:1}" appendQueryString="true"/>
</rule>
</rules>
</rewrite>
</system.webServer>
<system.web>
<customErrors mode="Off"/>
<compilation debug="true"/>
</system.web>
</configuration>
现在该网站已启动并正在运行。 感谢您的支持。
答案 1 :(得分:0)
我还不能评论,所以我会回答。
如果你有.htaccess
文件,如果你有权访问服务器,请检查项目根目录,如果mod_rewrite
已启用,也可以检查(假设您使用的是Apache) 。这可能是URL重写问题。
编辑1
好的,现在我看到你有一个.htaccess
文件。您的 httpd.conf 中的<Directory>
指令如何?或者是通过<VirtualHost>
进行设置?
编辑2
尝试使用此更改.htaccess
:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
#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 ^(.*)$ /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 ^(.*)$ /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 ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
# Submitted by: ElliotHaughin
ErrorDocument 404 /index.php
</IfModule>