0
votes

I developed a project which uses CodeIgniter on Windows OS. The project works fine on XAMPP (Windows) and Linux hosting server (updated .htaccess on server to work). I want to use Open Mandriva for development purpose. If I run the controller using index.php, it works.

I tried many .htaccess rules examples, links. But controller is not loading.

I tried: Cannot remove index.php from CodeIgniter URL, CodeIgniter removing index.php from url and this external link, and many other links.

.htaccess code on Windows machine

RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA] 

.htaccess code on Linux hosting server

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

Both are not working on Open Mandriva.

.htaccess path

/srv/www/html/ci/

The page gives:

404 error, and Object not found!

The file system path to my project is

/srv/www/html/ci/application/controllers/ 

and on browser:

localhost/ci/branch 

Project works if I add index.php like

localhost/ci/index.php/branch

Is it having any relation with http server config? Do I need to install any package. Also I tried some commands for apache rewrite engine. But I get error as unknown command.

2
Please could you share the current content of your .htaccess file? This will help us to help you. - Mike Rockétt
Where are your files stored? At the document root? And why do you need to check /system.*? - Mike Rockétt
.htaccess is stored at same level of application or system folder. Actually I am not having any knowledge about htaccess rules. The code worked so I kept it for respective platforms. - Paritosh
Off-topic: I recently commented on one of your answers, which you can copy-and-pasted from another of your answers. I think deleting the copy was the correct course of action, but why did you delete the original? That was fine: if that itself was not a copy, I suggest you reinstate it. - halfer

2 Answers

2
votes

Check if rewrite engine is enabled.

If not, enable rewrite engine and restart server.

sudo a2enmod rewrite
sudo service apache2 restart

Go to

/etc/httpd/conf/httpd.conf - for Mandriva
/etc/apache2/apache2.conf  - for Ubuntu

Change AllowOverride None to AllowOverride All

Code block:

# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
#   AllowOverride FileInfo AuthConfig Limit
#
AllowOverride All

Restart Apache(httpd) service.

No changes required in config.php or anywhere else.

.htaccess code:

RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
1
votes

Please try the following:

RewriteEngine on
RewriteBase /ci/
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [L,QSA]

Then, in config.php:

$config['index_page'] = "";
$config['uri_protocol'] = "REQUEST_URI";

Please ensure that your .htaccess is located in the same directory as your index.php.