1

I've looked a lot of provided solutions in this site and other, but can't seem to find something that works.

I've just downloaded Codeigniter and put it in htdocs folder from Xamp. Changed its name to 'notas'. Changed notas/config/config.php the properties like this

$config['base_url'] = 'http://localhost/notas/';
$config['index_page'] = '';

Created a .htaccess file in'notas' with many approaches. Currently, I have it like this

RewriteEngine On

RewriteBase /notas/
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*?)/?$ $1.php [NC,L]

and the URL http://localhost/notas/welcome returns Object not found - 404, where welcome is that default controller in the folder

If I put it like this, I get a 500 error

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 

If there is any other data I could provide to help solve it, please, ask for it

Thanks

EDIT

If I put the .htaccess file like

Satisfy all

or

Satisfy any

Still get 404. I've already rechecked that inside the controller folder exists a Welcome.php file

Mujahid Bhoraniya
  • 1,518
  • 10
  • 22
Silkking
  • 250
  • 3
  • 15

3 Answers3

1

Of course, I was the one who broke it in the first place. I changed the name of /notas/index.php file thinking it was like an example and wanted to see something different. After renaming it correctly and putting the following htaccess worked

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 

Thanks for the help. Thanks specially to Amit Sharma that made me realize this

Silkking
  • 250
  • 3
  • 15
0

In htaccess it should be something 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>

Base URL should be like this

$config['base_url'] = 'http://localhost/notas/';
$config['index_page'] = '';
Amit Sharma
  • 1,775
  • 3
  • 11
  • 20
0

You can use dynamic baseurl like this:

$config['base_url'] = "http://".$_SERVER['HTTP_HOST'];
$config['base_url'] .= preg_replace('@/+$@','', dirname($_SERVER['SCRIPT_NAME'])).'/';

And in htaccess :

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

And don't forget to set $config['index_page'] = 'index'; to $config['index_page'] = ''; in config.php

Egar
  • 3
  • 2