2017-01-23 62 views
-1

我試圖測試codeigniter proyect託管;它的渲染沒有問題的索引頁,但我有一個聯繫表格,通過ajax請求發送數據,在這裏:Codeigniter阿賈克斯調用404錯誤託管

$('#send_mail').submit(function(e) { 
e.preventDefault(); 

$.ajax({ 
    url: baseurl+'email/send', 
    type: 'POST', 
    dataType: 'json', 
    data: $(this).serialize() 
}) 
.done(function() { 
    console.log("success"); 
}) 
.fail(function() { 
    console.log("error"); 
}) 
.always(function() { 
    console.log("complete"); 
}); 

});

當我提交的聯繫方式,我得到這個錯誤:

POST http://novaderma.cl/site/email/send 404 (Not Found) jquery.min.js:4 

我一直在尋找在網絡上和其他人都與.htacces文件和base_url參數類似的問題,所以我會後他們也一樣,在這裏:

配置文件

$config['base_url'] = 'http://novaderma.cl/site/'; 
$config['index_page'] = 'index.php'; 

的.htaccess

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

我不知道如何解決這個問題,所以請幫助我!

+0

的可能的複製[IIS 7 URL重寫(http://stackoverflow.com/questions/14290837/ iis-7-url-rewriting) – Vaviloff

+0

您的服務器在Windows上的IIS上工作,所以.htaccess不會幫助,因爲它適用於Apache服務器。請參閱上面的URL以解決您的問題。 – Vaviloff

+0

Hi @Vaviloff! ,請你幫我解決這個問題嗎?我無法理解它。 –

回答

1

你的網站服務器工作在IIS的Windows這樣的.htaccess將沒有幫助,因爲它是一個Apache服務器。

您需要site文件夾中創建web.config文件,然後用folllowing規則填充:

<rewrite> 
     <rules> 
      <rule name="Clean URL" stopProcessing="true"> 
       <match url="^(.*)$" /> 
       <conditions> 
        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> 
        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> 
       </conditions> 
       <action type="Rewrite" url="/site/index.php/{R:1}" appendQueryString="true" /> 
      </rule> 
     </rules> 
    </rewrite> 
+0

偉大的人!!!!!!!就是這樣!!謝謝!!但我有另一個問題,我認爲這是與此有關....我試圖通過codeigniter發送電子郵件並拋出我有類似的錯誤...「不能發送電子郵件使用smtp的PHP,也許你的服務器沒有正確配置使用此發送方法」...任何想法?=( –

+1

偉大,很高興幫助。至於smtp問題 - 請打開另一個問題,因爲這是一個完整的其他問題。 – Vaviloff

+0

好的,我怎麼能把你添加到這個問題?...因爲你可以幫助我嗎? –

-1

`

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

`

檢查這個代碼