【发布时间】:2015-05-20 10:11:47
【问题描述】:
后端工作正常,但前端只有默认控制器工作,如果我调用默认控制器写入控制器和函数的名称然后它不工作
(给出 404 错误“在此服务器上找不到 indialive_today/home/。”)
.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /demo/indialive_today
#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 ^(.*)$ admin/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>
routes.php
$usertype=explode("/",$_SERVER["REQUEST_URI"]);
require_once( BASEPATH .'database/DB'. EXT );
$db =& DB();
$query = $db->get( 'news' );
$result = $query->result();
if($usertype[3] == ''){ $route['default_controller'] = "home/index"; }
else if($usertype[3] != ''){ foreach( $result as $row ){$route[$row->slug] = 'news_detail'; }
}
【问题讨论】:
-
据我所知,godaddy 共享服务器不允许您的本地 .httacess 文件。您可以要求他们解决它。或者您可以使用 /index.php/ 使用您的网址
-
如果您在 URL 中包含 index.php,您的应用程序是否正常工作?
-
前端工作正常问题
-
如果您在 URL 中包含 index.php,您的应用程序是否正常工作?无法确定应该显示什么。路由文件中没有指定默认路由。
标签: php .htaccess codeigniter routes server