Ajax + Codeigniter

Asked

Viewed 135 times

2

Good morning....

I just implemented Codeigniter, but I can’t use user friendly url...

I try to pass parameters through Ajax, but I cannot due to URLS.

I’ve already removed the index.php of the archive config.php and changed the routs.php

I have already inserted the following code in htaccess

RewriteEngine on

RewriteCond $1 !^(index\.php|assets|robots\.txt)

RewriteRule ^(.*)$ index.php/$1 [L]]  
  • What mistake does it make?

  • How is your Ajax and what is the error returned in the request?

  • error 404, the same happens if I try to access the function directly by url

  • $.ajax({ method: "POST", url: "<? php echo base_url('/login/realiza_login'); ? >", data: { login: login_front, password: password_front } }) });

  • Already tried to access the url directly by navagador, to see is working?

  • 1

    You have set the $config['base_url'] variable to your website url?

Show 1 more comment

1 answer

1

To make the server work with URL friendly you need, in addition to activating mod_rewrite module, also enable the Allowoverride directive (read here) in the hosting directory.

Just a word of advice: Everything an htaccess does, Apache must do with configuration files, and passing commands through configuration files is safer (developer says so). Knowing this, it might be better to set it up in the general server file anyway. So:

<Directory "/var/www/html/seu_sistema">
Options -Indexes
DirectoryIndex index.php index.html
AllowOverride All
RewriteEngine on
RewriteCond $1 !^(index\.php|assets|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]
</Directory>

Saw how Allowoverride All is it set? That’s it.

NOTE: with this setting, you no longer need to use the . htaccess.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.