2016-02-18 66 views
1

這是我上傳到在線服務器的第一個應用程序。我在CodeIgniter 3.0.1上創建了應用程序並將其上載到000webhost.com。但問題是,我的鏈接沒有被路由。我在網上檢查過,我的.htacess文件似乎是正確的。我檢查了這個問題My .htaccess file is not working,我遇到了和他一樣的問題,但是正確的答案沒有奏效。CodeIgniter不在服務器上路由

我的繼承人.htacess文件

DirectoryIndex index.php 

RewriteEngine on 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond $1 !^(index\.php|public|images|css|js|robots\.txt) 

RewriteRule ^(.*)$ index.php?/$1 [L] 
+1

whatz你的錯誤?你想達到什麼? –

+0

您需要在根文件夾中爲css,js等創建一個名爲「public」的文件夾。 –

+0

您能否提供錯誤信息?是500錯誤還是別的? –

回答

1
  1. 你能確保你已經創建了一個特殊的「控制器」 &它的「法」到你想的路線?我的意思是你可以從字面上驗證他們的拼寫?

  2. 你能也嘗試創建一個規則:

$route['club'] = 'welcome/index';

你可以看到,如果上述規則適用與否?你有沒有其他的控制器的名字'club.php'?

+0

是的。一切工作正常我的本地服務器上。它只是在網絡主機上不起作用 –

+0

上述步驟2不起作用? – tovishalck

+0

不,它沒有工作 –

-1

試試這個,告訴我們,如果它的工作原理:

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



附:我希望你的文件是「的.htaccess」(不.htacess)

,如果它仍無法正常工作,嘗試添加該在它的頂部編輯index.php文件:

<?php 

echo $_SERVER['REQUEST_URI']; 
die; 

這必須顯示你的htaccess正確地重寫到index.php文件。
如果仍然無法正常工作,請與託管支持聯繫。

BTW從這裏取這個片段中,有許多感謝:https://gist.github.com/philipptempel/4226750

+0

我試過.htaccess,它沒有工作。 echo $ _SERVER ['REQUEST_URI'];返回 - > \ –

+0

@RosárioPereiraFernandes在所有情況下?你試過在瀏覽器中打開:http://yoursite.com/something? – num8er

-1

既然你提到的404錯誤。你能確保所有的項目文件夾都有適當的執行權限嗎?

將權限設置爲0755到項目文件夾及其所有子文件夾。

然後試試看。

-1

爲了確保錯誤的部分是.htaccess文件,您需要在路徑上使用index.php訪問您的網站。

例如,您需要訪問http://example.com/index.php/book而不是http://example.com/book

如果可以訪問第一個URL,那麼很可能是您的.htaccess不正確。

我通常在我的笨工程船舶此.htaccess

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

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

而在去年,請確保您的rewrite國防部在Apache服務器啓動(請聯繫您的託管服務提供商如果使用共享的主機)。

要激活它,運行這個命令:

sudo a2enmod rewrite 

然後,重新啓動服務:

sudo service apache2 restart 

希望它能幫助。

-1

我需要註冊000webhost並檢查子域結構來解決這個問題。正如我懷疑的那樣,它爲子域創建了一個文件夾。因此,您的.htaccess文件無法正常工作。您需要將子目錄作爲rewritebase:

DirectoryIndex index.php 

RewriteEngine on 
RewriteBase /sigede/ 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond $1 !^(index\.php|public|images|css|js|robots\.txt) 

RewriteRule ^(.*)$ index.php?/$1 [L] 
相關問題