2015-05-26 121 views
1

我在codeigniter路由中遇到了一些麻煩。我有一個託管服務器的活網站&這裏是它的htaccess。本地主機的Codeigniter htaccess

#php_value memory_limit 256M 
#php_value upload_max_filesize 50M 
#php_value post_max_size 70M 

AddType font/opentype .otf 
AddType application/vnd.ms-fontobject .eot 
AddType font/ttf .ttf 
AddType application/font-woff .woff 

AddDefaultCharset utf-8 

<IfModule mod_rewrite.c> 
    RewriteEngine on 
    Options +FollowSymLinks 
    RewriteBase/

    RewriteRule ^favicon.* - [L] 

    RewriteRule ^search /categories [R=301,L] 
    RewriteRule ^login/[R=301,L] 
    RewriteRule ^pages/disclaimer /pages/integritetspolicy [R=301,L] 

    RewriteRule ^(.*)/$ http://%{HTTP_HOST}/$1 [R=301,L] 

    RewriteRule ^index.php$ http://%{HTTP_HOST} [R=301,L] 

    RewriteCond %{HTTP_HOST} !^example\.com 
    RewriteRule (.*) http://example.com/$1 [R=301,L] 

    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteRule ^(.*)$ index.php/$1 

    RewriteCond %{HTTPS} off 
    RewriteCond %{REQUEST_URI} (utredningar/post) 
    RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301] 

    RewriteCond %{HTTPS} on 
    RewriteCond %{REQUEST_URI} !(utredningar/post) 
    RewriteRule ^(.*)$ http://%{HTTP_HOST}%{REQUEST_URI} [R=301] 
</IfModule> 

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

這與域名(example.com)&託管服務器完美的作品。在其他視圖header.view &鏈接給出

<href="/assets/styles/home.css?9"> 

但是,當我試圖讓在本地主機WAMP這項工作,這是行不通的。 Assets(css/js/images)不加載& url路由不起作用。

我已經這兩行

RewriteCond %{HTTP_HOST} !^example\.com 
RewriteRule (.*) http://example.com/$1 [R=301,L] 

修飾以

RewriteCond %{HTTP_HOST} !^localhost 
RewriteRule (.*) http://localhost/example/$1 [R=301,L] 

我改變應用程序/配置/ config.php中,加入鹼的url,取出的index.php等。

我已盡全力讓它工作,請指出我在哪裏做錯了..非常感謝

+0

您使用CI的哪個版本的根目錄? – Saty

+0

這是2.1,但我已將系統更改爲2.2以及..仍不起作用.. –

+0

您使用的是godaddy服務器嗎? –

回答

1

這是我的.htaccess它在生產發展服務器。

RewriteEngine on 
RewriteCond $1 !^(index\.php|resources|robots\.txt) 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php?/$1 [L,QSA] 

的config.php

$config['base_url'] = ''; 
$config['index_page'] = ''; 

routes.php文件

# Default 
$route['default_controller'] = "home"; 
+0

感謝你的快速回復@Parag,但我之前已經嘗試過了。 。 –

+0

只是一個猜測工作,嘗試其他一些調整編輯 –

+0

好的我會.. ..感謝您的幫助 –

0

詞根記憶在application/config.php文件的變化下面

$config['base_url'] = 'http://'.$_SERVER['SERVER_NAME'].'/Your Ci folder_name'; 
$config['index_page'] = ''; 
$config['uri_protocol'] = 'AUTO'; 

2.Make .htacces文件中使用下面的代碼

RewriteEngine on 
RewriteBase /codeigniter   // add this 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php/$1 [L,QSA] 
+0

我已經完成了那些......仍然沒有運氣:( –

+0

@UdayaSri小在我的代碼修改RewriteBase/codeigniter – Saty

+0

@stay也試過,..也沒有工作..感謝您持續的幫助.. –