【发布时间】:2015-08-19 12:12:03
【问题描述】:
我在 codeigniter 中的路由文件有问题。在 Wamp 上,我的路线运行正常。但是,在我的服务器(共享主机)上,我的路由没有运行。
我的主页在 fr 文件夹中。我的控制器是索引。所以我的默认控制器是'fr/index'。
$route['default_controller'] = 'fr/index';
$route['404_override'] = '';
当我写 www.domainName.tld 时,我得到“找不到文件”。没有 CSS 样式。在源代码中我有
1 文件未找到。
2
当我写 www.domainName.tld/aaaa(404 错误)时,我确实遇到了 404 错误:
<!DOCTYPE html>
<html lang="en">
<head>
<title>404 Page Not Found</title>
<style type="text/css">
::selection{ background-color: #E13300; color: white; }
::moz-selection{ background-color: #E13300; color: white; }
::webkit-selection{ background-color: #E13300; color: white; }
body {
background-color: #fff;
margin: 40px;
font: 13px/20px normal Helvetica, Arial, sans-serif;
color: #4F5155;
}
a {
color: #003399;
background-color: transparent;
font-weight: normal;
}
h1 {
color: #444;
background-color: transparent;
border-bottom: 1px solid #D0D0D0;
font-size: 19px;
font-weight: normal;
margin: 0 0 14px 0;
padding: 14px 15px 10px 15px;
}
code {
font-family: Consolas, Monaco, Courier New, Courier, monospace;
font-size: 12px;
background-color: #f9f9f9;
border: 1px solid #D0D0D0;
color: #002166;
display: block;
margin: 14px 0 14px 0;
padding: 12px 10px 12px 10px;
}
#container {
margin: 10px;
border: 1px solid #D0D0D0;
-webkit-box-shadow: 0 0 8px #D0D0D0;
}
p {
margin: 12px 15px 12px 15px;
}
</style>
</head>
<body>
<div id="container">
<h1>404 Page Not Found</h1>
<p>The page you requested was not found.</p> </div>
</body>
</html>
我的 .HTACCESS 运行正常:
Options +FollowSymLinks
RewriteEngine on
#Sub-dir e.g: /cmsms
#RewriteBase /
#
# 301 Redirect all requests that don't contain a dot or trailing slash to
# include a trailing slash
RewriteCond %{REQUEST_URI} !/$
RewriteCond %{REQUEST_URI} !\.
RewriteRule ^(.*) %{REQUEST_URI}/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?page=$1 [QSA]
# Empêche la visualisation de l’arborescence, n’a rien à voir avec le masquage du « index.php ». Options -Indexes
# Active le module de réécriture d’URL. RewriteEngine on
# Toutes les URL qui ne correspondent pas à ces masques sont réécrites.
RewriteCond $1 !^(index.php|assets/|robots.txt)
# Toutes les autres URL vont être redirigées vers le fichier index.php.
RewriteRule ^(.*)$ index.php/$1 [L]
我认为是托管问题,因为在 wamp 上,我的指令可以正确运行,但不能在我的服务器上运行。
你有什么想法吗?
感谢您的回答。
【问题讨论】:
-
你检查过你的配置文件的
$config['base_url']吗? -
是的。我的 base_url 是空的。当我创建链接时,我使用了 base_url (localhost),因为我的文件结构在服务器中。
-
将您的服务器 url 分配给 base_url 并重试
-
我也有同样的问题。现在,当我尝试访问我的主页时,我有很多指向 404 错误的链接。始终找不到我的主页的文件 =/
-
你分配给 base_url 的 url 是什么?
标签: php codeigniter routes shared-hosting