Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I'm trying to test a codeigniter proyect on hosting; the index page it's rendering without problems, but I have a contact form that sends data via an ajax request, here:

$('#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");
});

});

When I submit the contact form I'm getting this error:

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

I've been searching on the web and other people have similar problems with the .htacces file and base_url parameter, so I'm gonna post them too, here:

Config file

$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>

I don't know how to solve this, so please help me !!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
316 views
Welcome To Ask or Share your Answers For Others

1 Answer

Your site server works on IIS on Windows so .htaccess won't help because it's for an Apache server.

You need to create web.config file in site folder, then fill it with the folllowing rule:

<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>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...