2014-01-11 38 views
0

我正在使用CodeIgniter稱爲PHP和MVC的參考書,我正在關注項目放入我的個人電腦的例子。它在我的本地PC上運行良好,但在Web服務器上出現錯誤。診斷:有問題的問題是頁面路徑。在我的個人電腦正常工作,但是當我把它放在Web服務器上找不到請求的頁面。頁面路由CodeIgniter我

http://orion.locadados.com.br/~wladi/Carrinho_Compras/ 
http://orion.locadados.com.br/~wladi/Carrinho_Compras/categoria/artigos-esportivos 

在我的項目中定義的路由作爲默認的任何服務器,因爲它們在項目文件夾本身。只是不要把代碼行,它不知道哪部分代碼放在線上。

我該如何解決這個問題?

文件的.htaccess

RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} -s [OR] 
RewriteCond %{REQUEST_FILENAME} -l [OR] 
RewriteCond %{REQUEST_FILENAME} !-d 

RewriteRule ^.*$ - [NC,L] 
RewriteRule ^.*$ index.php [NC,L] 

文件routes.php文件

<?php if (! defined('BASEPATH')) exit('No direct script access allowed'); 
/* 
| ------------------------------------------------------------------------- 
| URI ROUTING 
| ------------------------------------------------------------------------- 
| This file lets you re-map URI requests to specific controller functions. 
| 
| Typically there is a one-to-one relationship between a URL string 
| and its corresponding controller class/method. The segments in a 
| URL normally follow this pattern: 
| 
| example.com/class/method/id/ 
| 
| In some instances, however, you may want to remap this relationship 
| so that a different class/function is called than the one 
| corresponding to the URL. 
| 
| Please see the user guide for complete details: 
| 
| http://codeigniter.com/user_guide/general/routing.html 
| 
| ------------------------------------------------------------------------- 
| RESERVED ROUTES 
| ------------------------------------------------------------------------- 
| 
| There area two reserved routes: 
| 
| $route['default_controller'] = 'welcome'; 
| 
| This route indicates which controller class should be loaded if the 
| URI contains no data. In the above example, the "welcome" class 
| would be loaded. 
| 
| $route['404_override'] = 'errors/page_missing'; 
| 
| This route will tell the Router what URI segments to use if those provided 
| in the URL cannot be matched to a valid route. 
| 
*/ 


$route['default_controller'] = "home"; 
$route['categoria/(:any)'] = "home/categoria/$1"; 
$route['produto/(:any)'] = "produtos/detalhes_produto/$1"; 

$route['404_override'] = ''; 

/* End of file routes.php */ 
/* Location: ./application/config/routes.php */ 

回答

0

嘗試與此的.htaccess:

<IfModule mod_rewrite.c> 
    RewriteEngine On 
    RewriteBase/

RewriteCond %{REQUEST_URI} ^sys.* 
RewriteRule ^(.*)$ /index.php?/$1 [L] 

RewriteCond %{REQUEST_URI} ^app.* 
RewriteRule ^(.*)$ /index.php?/$1 [L] 

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

<IfModule !mod_rewrite.c> 
    ErrorDocument 404 /index.php 
</IfModule> 

假設你的系統文件夾是SYS和應用文件夾是app

+0

這是改變htaccess文件的方法是什麼? Http://suporte.netpoint.com.br/habilitar-mod-rewrite-no-cpanel/ – wladyband

0

對我來說這htaccess的工作原理與最新的CI版本

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

嘗試用這種