2

this is the first application that I upload to an online server. I created the application on CodeIgniter 3.0.1 and uploaded it to the 000webhost.com . But the problem is, none of my links are being routed. I have checked online and my .htacess file seems to be correct. I have checked this question My .htaccess file is not working and I have the same problem as He does, but the correct answer didnt work.

Heres my .htacess file

DirectoryIndex index.php

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|public|images|css|js|robots\.txt)

RewriteRule ^(.*)$ index.php?/$1 [L]
Community
  • 1
  • 1

6 Answers6

1
  1. Can you make sure you have created that particular "controller" & it's "method" to which you are trying to route? I mean can you literally verify their spellings?

  2. Can you also try to create a rule:

$route['club'] = 'welcome/index';

Can you see if the above rule works or not? Do you have any other controller by the name of 'club.php'?

tovishalck
  • 990
  • 8
  • 18
  • Yes. Everything works fine on my local server. It just doesn't work on the webhost – Rosário Pereira Fernandes Jul 12 '16 at 11:24
  • 1. Do you have your $config['base_url'] set? If it's blank, can you set that to your base url & see? 2. Does creating any other route work at all? For example: `$route['abc'] = 'welcome/index';` Does something like this work? – tovishalck Jul 12 '16 at 15:56
  • 1. Yes, it is set as following: $config['base_url'] = 'http://sigede.comli.com/'; 2. No, creating other route doesnt work at all. – Rosário Pereira Fernandes Jul 12 '16 at 18:59
  • Does it help if you temporarily remove the htaccess file & then see if it loads those routes? – tovishalck Jul 12 '16 at 19:11
  • I did remove the htaccess and it doesn't load. – Rosário Pereira Fernandes Jul 12 '16 at 19:40
  • Thanks for trying it out. I assume on your localhost you don't have a subdomain setup? Can you change your last line in .htaccess file to this: `RewriteRule ^(.*)$ /index.php?/$1 [L]` ? – tovishalck Jul 13 '16 at 03:42
  • I think we're getting somewhere now. I've changed that last line. Now the 'abc' route works, but the others don't work. – Rosário Pereira Fernandes Jul 13 '16 at 08:17
  • I see. Can you show what your route file looks like with the 'abc' route as well as the 'club' route which doesn't work? I do see that 'abc' does indeed show the proper page. – tovishalck Jul 13 '16 at 08:20
  • I renamed my controllers. Capitalized the first letter. Now it works correctly. Thank you very much :) – Rosário Pereira Fernandes Jul 13 '16 at 08:26
  • Good to know. So you renamed the controller files from let's say: 'sigede.php' to 'Sigede.php' ? I still see 404s on your site though based on the routes file you provided earlier. Thank you for the bounty & marking the answer. :) – tovishalck Jul 13 '16 at 08:32
  • Yes, i renamed it from 'sigede.php' to 'Sigede.php' and 'class sigede extends CI_Controller' to 'class Sigede extends CI_Controller'. Yes, those 404's are because I'm changing some stuff there. You are welcome – Rosário Pereira Fernandes Jul 13 '16 at 08:35
1

I had same problem with you.

check .htaccess is hidden or not, if hidden try show hidden file, and voila

IBO
  • 11
  • 1
-1

Try this and tell us if it works:

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



p.s. I hope Your file is ".htaccess" (not .htacess)

if it's still not working, try to edit index.php file by adding this on the top of it:

<?php

echo $_SERVER['REQUEST_URI'];
die;

this must show You that htaccess properly rewriting to index.php file.
if still not getting proper work, contact to hosting support.

btw this snippet taken from here and has many thanks: https://gist.github.com/philipptempel/4226750

num8er
  • 18,604
  • 3
  • 43
  • 57
-1

Since you have mentioned as 404 error. Can you make sure all the project folders have proper permission to execute ?

Set permission as 0755 to the project folder and all its sub folder.

Then give it a try.

-1

To ensure that the wrong part is .htaccess file, you need to access your website with index.php on the path.

For example, you need to visit http://example.com/index.php/book instead of http://example.com/book.

If the first URL can be accessed, then it is likely your .htaccess is not correct.

I typically ship this .htaccess in my CodeIgniter project:

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

<IfModule !mod_rewrite.c>
  ErrorDocument 404 /index.php
</IfModule>

And last, please ensure that your rewrite mod is activated in your Apache server (contact your hosting provider if you use shared hosting).

To activate it, run this command:

sudo a2enmod rewrite

Then, restart the service:

sudo service apache2 restart

Hope it helps.

Teddy Aryono
  • 350
  • 2
  • 10
-1

I needed to register 000webhost and check the subdomain structure for solving that problem. As I suspected, it's creates a folder for subdomain. Therefore your .htaccess file is not working correctly. You need to point subfolder as rewritebase:

DirectoryIndex index.php

RewriteEngine on
RewriteBase /sigede/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|public|images|css|js|robots\.txt)

RewriteRule ^(.*)$ index.php?/$1 [L]
mirza
  • 5,685
  • 10
  • 43
  • 73