CodeIgniter Forums
[Error 404] Routing vs htaccess - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forum-5.html)
+--- Forum: General Help (https://forum.codeigniter.com/forum-24.html)
+--- Thread: [Error 404] Routing vs htaccess (/thread-70775.html)



[Error 404] Routing vs htaccess - ash - 05-29-2018

Hello all,

I am new to CI and this is my first application (project name: codeigniter).

I have a single controller named : Reports

which consists of 2 methods :

public function index() => [I assumes this is the default and it redirects to view('pages/logcatcher')]

public function flowmetercatcher() => [redirects to view('pages/flowmetercatcher')]

I have already removed the index.php using my htaccess file
Code:
RewriteEngine On
RewriteBase /codeigniter/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]

$config['base_url'] = 'http://monitor.vbu.fr/codeigniter';

When i acccess the above link, it works well but then i click the flowmetercatcher page, i get an 404 error.

Here is my routes :
Code:
$route['default_controller'] = 'reports';
$route['(:any)'] = 'reports/$1';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;



I have tried to view the page source but could't figured it out.
Code:
<li class="nav-item active">
     <a class="nav-link" href="http://monitor.vbu.fr/codeigniter/">LOGCATCHER</a>
</li>
<li class="nav-item ">
     <a class="nav-link" href="http://monitor.vbu.fr/codeigniter/flowmetercatcher">FLOWMETERCATCHER</a>
</li>

Can someone tell me what i am missing please ?

Thank you in advance.

Best regards, ash


RE: [Error 404] Routing vs htaccess - php_rocs - 05-29-2018

@ash,

I hate to assume but did you follow the instructions in the documentation ( https://codeigniter.com/user_guide/general/urls.html?highlight=index%20php#removing-the-index-php-file )?

Also, does your apache server have mod_rewrite enabled?


RE: [Error 404] Routing vs htaccess - InsiteFX - 05-29-2018

Try replacing this.
PHP Code:
$route['(:any)'] = 'reports/$1';

// with this
$route['reports/(.+)'] = 'reports/$1'



RE: [Error 404] Routing vs htaccess - ash - 05-30-2018

(05-29-2018, 12:44 PM)php_rocs Wrote: @ash,

I hate to assume but did you follow the instructions in the documentation ( https://codeigniter.com/user_guide/general/urls.html?highlight=index%20php#removing-the-index-php-file )?  

Also, does your apache server have mod_rewrite enabled?

Hello,

Thank you for your reply.
Indeed, the mod_rewrite was not enabled.

But as i am hosting the application within an IIS server, i was able to activate it using the web plateform.
https://manage.accuwebhosting.com/knowledgebase/2415/How-to-Enable-modrewrite-on-IIS-Web-Server.html

Thanks you very much. The issue is now solved.

Best regards,
ash