0

I am creating a website on localhost in xampp. It is working correctly with routes working as well. Path was 'localhost/mywebsite'.

I uploaded that website to live server. Path is 'www.mywebsite.com/beta/'. The website is not working. Only index page is working. When I click on any other link, It says 'File not found.'.

Any suggestions would be appreciated.

This is my routes.

$route['default_controller'] = 'front/index';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;

/*admin*/
$route['admin'] = 'user/admin';
$route['admin/login'] = 'user/admin';
$route['admin/logout'] = 'user/logout';
$route['admin/persons'] = 'person';
$route['admin/categories'] = 'category';
$route['admin/games'] = 'game';
$route['admin/login/validate_credentials'] = 'user/validate_credentials';

/*Front End*/
$route['category/(:num)'] = "front/category/$1";
$route['game/(:num)'] = "front/game/$1";
$route['search'] = "front/search";

This is my config.php

$config['base_url'] = 'http://mywebsite.com/beta/';
$config['index_page'] = '';

And my .htaccess

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L] 
Ali Zia
  • 3,825
  • 5
  • 29
  • 77
  • Sounds like you have an issue with your paths. I suggest you take a look at either your http servers access or error log file to see what files are actually requested or you take a look into your browsers development console and examine the requests in there, comes out the same. – arkascha Oct 12 '16 at 10:02
  • How come they are working fine on localhost but not on live server? – Ali Zia Oct 12 '16 at 10:03
  • That is a question you can answer by doing what I wrote above. – arkascha Oct 12 '16 at 10:04
  • make sure your controller and model file name first letter is capital – Muhammad Talha Oct 12 '16 at 10:05

3 Answers3

3
-Change your htaccess code and replace this code.

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
Rax Shah
  • 531
  • 5
  • 18
2

I was having the same issue when I tried to setup in a sub-directory. This is how I had a solution in my case:

STEP-1: Update the /beta/.htaccess like below-

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

STEP-2: Update the 'base_url' in the file: /beta/application/config/config.php as mentioned here -

$config['base_url'] = 'http://www.mywebsite.com/beta'; 
....
$config['index_page'] = '';
Reza Mamun
  • 5,991
  • 1
  • 43
  • 42
0

Update your .htaccess to look like following:

RewriteEngine On
RewriteBase /beta

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]

Let me know if it worked for you.

d.coder
  • 1,988
  • 16
  • 23
  • Then i am sure your .htaccess is not working on your server. Can you check and confirm whether it is working or not? Also, chose any URL other than HOME page where it says `File not found` and try adding `index.php` before controller name and then hit again. Check if this is working? – d.coder Oct 12 '16 at 10:12
  • `index.php/front/game/499` works instead of `game/499` – Ali Zia Oct 12 '16 at 10:14
  • That means .htaccess not working on your server. Please check mod_rewrite module enabled? [how you can check](http://stackoverflow.com/questions/9234289/how-to-debug-htaccess-rewriterule-not-working) – d.coder Oct 12 '16 at 10:57