Error 404 in Codeigniter project published in Azure Cloud Web App

0

Well, I am new by launching this type of project and for the moment I am trying to configure a codeigniter project within the Azure cloud portal, through a web app. The issue is that I get a 404 error when trying to access the credential validation method in the login, and I guess it will be the same for the other controller methods. It seems like it only takes into account the default_controller.

I have the folders in the following way:

xpbc2017
   application
   config
                routes.php
                database.php
                config.php
    views
    controllers
               login
                      backend
                              ValidateUser.php
               usuario
               Login.php
      models
      system
      templates
      web.config
      index.php

This is my web.config

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
       <rewrite>
         <rules>
           <rule name="Rule" stopProcessing="true">
             <match url="^(.*)$" ignoreCase="false" />
             <conditions>
               <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
               <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
               <add input="{URL}" pattern="^/favicon.ico$" ignoreCase="false" negate="true" />
               <add input="{REQUEST_FILENAME}" pattern="^.+\.(css|js|jpg|jpeg|png|gif|ico|htm|html|eot|woff|ttf|svg|txt|pdf|swf)$"  matchType="IsFile"  negate="true" />
             </conditions>
             <action type="Rewrite" url="index.php/{R:1}" appendQueryString="true" />
           </rule>
         </rules>
       </rewrite>
     </system.webServer>
</configuration>

This is my config

<?php 
defined('BASEPATH') OR exit('No direct script access allowed');
$config['base_url'] = 'https://xpbc-app-2018.azurewebsites.net/';
$config['index_page'] = 'index.php';
$config['uri_protocol'] = 'REQUEST_URI';
$config['url_suffix'] = '';
$config['language']     = 'english';
$config['charset'] = 'UTF-8';
$config['enable_hooks'] = FALSE;
$config['subclass_prefix'] = 'MY_';
$config['composer_autoload'] = FALSE;
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-';
$config['enable_query_strings'] = FALSE;
$config['controller_trigger'] = 'c';
$config['function_trigger'] = 'm';
$config['directory_trigger'] = 'd';
$config['allow_get_array'] = TRUE;
$config['log_threshold'] = 0;
$config['log_path'] = '';
$config['log_file_extension'] = '';
$config['log_file_permissions'] = 0644;
$config['log_date_format'] = 'Y-m-d H:i:s';
$config['error_views_path'] = '';
$config['cache_path'] = '';
$config['cache_query_string'] = FALSE;
$config['encryption_key'] = 'pass';
$config['sess_driver'] = 'files';
$config['sess_cookie_name'] = 'cisession';
$config['sess_expiration'] = 0;
$config['sess_save_path'] = NULL;
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;
$config['cookie_prefix']        = '';
$config['cookie_domain']        = '';
$config['cookie_path']          = '/';
$config['cookie_secure']        = FALSE;
$config['cookie_httponly']      = FALSE;
.
.

and this my routes.php

$route['default_controller'] = 'login';
$route['login'] = 'login/frontend/Login';
$route['validateUser'] = 'login/backend/ValidateUser/newUser';
$route['menu_principal'] = 'MainMenu';
$route['usuario-agregarUsuario'] = 'usuario/AgregarUsuario';
$route['usuario-modificarUsuario'] = 'usuario/ModificarUsuario';
$route['usuario-eliminarUsuario'] = 'usuario/EliminarUsuario';
$route['usuario-consultarUsuario'] = 'usuario/ConsultarUsuario';

This topic has really given me headaches and that's why I'm here asking for your help, some advice or a clue as to what I might be doing, and I thank you in advance for those who take the trouble to comment.

Thank you very much.

    
asked by Aryam Zav 14.10.2018 в 01:28
source

1 answer

0

Your website by filling in the form and sending it redirects to:

https://xpbc-app-2018.azurewebsites.net/login/validateUser

I see that you are not eliminating the index.php of index_page therefore the url should be:

https://xpbc-app-2018.azurewebsites.net/index.php/login/validateUser

In any case, if you want to remove the index.php from your website, you can do so by means of a .htaccess file at the root of the site, which should contain the following:

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

Therefore your $config['index_page'] should be empty:

$config['index_page'] = '';

Therefore when you send the post of your form you will send it through your base_url() and your controller:

action="<?echo base_url('login/validateUser')?>"

It is worth mentioning that recently I had the same problem and everything was caused because the base_url() was not well defined, in the local it worked well, but when uploading it I threw those errors.

    
answered by 14.10.2018 в 20:59