-1

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

Master Yoda
  • 55
  • 10
  • Possible duplicate of [IIS 7 URL Rewriting](http://stackoverflow.com/questions/14290837/iis-7-url-rewriting) – Vaviloff Jan 23 '17 at 06:51
  • Your server works on IIS on Windows so .htaccess won't help because it's for Apache server. See the URL above for solution to your problem. – Vaviloff Jan 23 '17 at 06:52
  • Hi @Vaviloff! , please would you help me to get solution for this problem ? I can't understand it . – Master Yoda Jan 23 '17 at 18:05
  • @Vaviloff Great man !!!!!!! that's it !! thank you !! but I have another problem, I'm thinking it's related to this....I'm trying to send an email by codeigniter and throws me a similar error..."Can't send email using smtp php, maybe your server is not properly configured to use this send method"...any idea ? =( – Master Yoda Jan 24 '17 at 20:55

2 Answers2

1

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>
Vaviloff
  • 16,282
  • 6
  • 48
  • 56
  • Great man !!!!!!! that's it !! thank you !! but I have another problem, I'm thinking it's related to this....I'm trying to send an email by codeigniter and throws me a similar error..."Can't send email using smtp php, maybe your server is not properly configured to use this send method"...any idea ? =( – Master Yoda Jan 24 '17 at 20:52
  • 1
    Great, was glad to help. As for smtp problems - please open another question, as it's a whole other issue. – Vaviloff Jan 25 '17 at 01:19
  • Ok , and how could I add you to that question ? ...for you can help me ? – Master Yoda Jan 25 '17 at 01:51
-1

`

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

`

check this code

Ganesh Aher
  • 1,118
  • 3
  • 21
  • 51