Reputation: 987
Updated, I'm having some issues with deploying codeigniter project on Ubuntu server, i get 404 Apache error when i click on links.
When i put the project in http://roy.my-domain.com/ = /var/www/html/ folder - it's all works fine - but when i added sub directory http://roy.my-domain.com/roy/ = /var/www/html/roy/ - i get 404 errors .
When my url is http://roy.my-domain.com/roy/index.php/about - i get codeigniter 404 error and not apache2.
The error :
Not Found
The requested URL /index.php was not found on this server.
Apache/2.4.18 (Ubuntu) Server at roy.my-domain.com Port 80
Here are my settings :
0 . Checked for rewrite mod in Apache - got "Module rewrite already enabled"
1 . My project is in /var/www/my-project/
2 . In contains the following : application system public_html index.php .htaccess
The .htaccess file :
< IfModule mod_rewrite.c > RewriteEngine On RewriteBase /html/my-project/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d
# Rewrite all other URLs to index.php/URL RewriteRule ^(.*)$ index.php?url=$1 [PT,L]
< /IfModule > < IfModule !mod_rewrite.c> ErrorDocument 404 index.php < /IfModule >
The apache2.conf :
< Directory /var/www/ > Options Indexes FollowSymLinks Require all granted < /Directory >
< Directory /var/www/html/ > Options Indexes FollowSymLinks AllowOverride All Require all granted < /Directory >
The config.php :
$config['base_url'] = 'http://roy.my-domain/my-project/'; $config['index_page'] = ''; $config['uri_protocol'] = 'AUTO';
The index.php :
(don't work with ../system and ../application) $system_path = 'system'; $application_folder = 'application';
The controllers :
(codeigniter default view) Welcome.php About_Controller.php
The views: (codeigniter default view) welcome_message.php about.php
Locally - all works fine...Thanks
Upvotes: 1
Views: 31956
Reputation: 770
This error can be triggered by the following:
server misconfiguration (httpd.conf)
.htaccess issues
mod_security or similar
Upload your project in "var/www/my_project".
In config file:
$config['base_url'] = '';
$config['index_page'] = '';
Add this code into your .htaccess file to remove index.php and put this .htaccess file in main folder.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Rewrite all other URLs to index.php/URL
RewriteRule ^(.*)$ index.php?url=$1 [PT,L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 index.php
</IfModule>
And Set AllowOverride to All
in your httpd.conf
set the correct permission on the /cache folder, rather than just making the folder writable you need to make it reclusively writable.
I hope it will work for you.
Upvotes: 5
Reputation: 2708
A simple step for setup CodeIgniter.
Open your project as URL : https://example.com/project . If you get welcome CodeIgniter message then you have to install CodeIgniter successfully.
Make sure, mod_rewrite enabled on your server.
<IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [L] </IfModule>
I think it will be the complete process for setup the project.Make sure mod_rewrite enable on server. Thanks
Upvotes: 3
Reputation: 827
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
.htaccess:
RewriteEngine On
RewriteBase /html/project/
RewriteCond %{THE_REQUEST} \s/+(.*?)/{2,}([^\s]*)
RewriteRule ^ %1/%2 [R=302,L,NE]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+(.+?)/{2,}[?\s] [NC]
RewriteRule ^ /%1/ [L,R=301]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteCond %{REQUEST_URI} system|application
RewriteRule ^(.*)$ index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
Try this configuration and don't forget to reload Apache.
Upvotes: 3