1

Helllo everybody. I am desperatly trying to get codeigniter run on a webserver. The apache mod_rewrite is enabled, and I tried almost everything related i found on the internet, but nothing worked.

The directory on the webserver is

enter image description here

The cgi-bin folder have been already there. Posts that i have read said, the cgi-bin folder is irrelevant since it is hardly used these days. But here is the first question: Holds this for me, too? Which .htaccess File should i use? Why is an .htaccess file put there?

None of them seems to work: I tried several settings and I ended up with the following version for both .htaccess files:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /test94252.test-account.com
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /test94252.test-account.com/index.htm [L]
</IfModule>

My goal is simply that if i call the domain http://website.com/ that /website/application/views/index.php is called. What is wrong with this .htaccess file?

EDIT: on my local machine i go by http://localhost/website/Controller/Function for calling that index.php file.

Please note: For the sake of testing i put a index.htm into /website/ to check whether the redirect is done, but it is not working.

I am looking forward hearing from you.

Community
  • 1
  • 1
J. Bug
  • 152
  • 1
  • 10

1 Answers1

3

First:

No, you should safe-delete it. cgi-bin historically was the only place where executable or script code (binaries, shell scripts, etc.) could be stored. It is mostly a historic relic since most hosts allow execution of scripts from anywhere.

When a .htaccess file is placed in a directory which is in turn 'loaded via the Apache Web Server', then the .htaccess file is detected and executed by the Apache Web Server software. .htaccess can be content password protection or image hot link prevention.

Second:

You should edit .htaccess in ./website folder.

And:

My file .htaccess run in server like this:

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

Updated:

Let tried again with another method.

  1. Make below changes in application/config.php file

    $config['base_url'] = 'http://'.$_SERVER['SERVER_NAME'].'/Your Ci folder_name';
    $config['index_page'] = '';
    $config['uri_protocol'] = 'AUTO';
    
  2. Make .htaccess file in your root directory using below code

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

Note: remove <IfModule mod_rewrite.c></IfModule>

Ave
  • 4,338
  • 4
  • 40
  • 67
  • thank you vanloc, so if i understand this right i can go with any .htaccess file since it does not matter where it is located. But still it is not working. When i look at your file it is partwise similar to https://www.codeigniter.com/userguide3/general/urls.html. But I don't understand how I'm going to tell apace where to find /application/views/index.php – J. Bug Mar 09 '17 at 10:21
  • It is directing to /index.htm, like there wouldn't be any .htaccess file – J. Bug Mar 09 '17 at 10:22
  • thank you for your effort. i checked and updated all values in config and removed the tag . But still no effect, that means /index.htm is loaded. – J. Bug Mar 09 '17 at 10:41
  • Try checking in `application/config/routes.php`. Please post values of your `$route['default_controller']` and `application/config/config.php` at line: `$config['base_url']` – Ave Mar 09 '17 at 10:46
  • $route['default_controller'] = 'pages/view'; Till now i have never thought about the default_controller. – J. Bug Mar 09 '17 at 10:48
  • your way seems to be the solution in most cases, as i could recognize from crawling through the web for a solution, but somehow it is not working, yet. :( – J. Bug Mar 09 '17 at 16:34
  • It is working. Right now i am out of time but your solution is correct. the problem were something else. I'll pick a moment of quit to give a full explanation of my problem in a couple of days. Thank you very much again for your comprehensive solution. – J. Bug Mar 13 '17 at 16:09
  • You are welcome. I very excited when my answer is helpful for you – Ave Mar 13 '17 at 16:36