0

I've tried going over similar questions asked here before and tried out couple of solutions, however, they doesn't seem to work.

I have a folder called "projectX" in my localhost root directory which is a CodeIgniter project

This project has a controller called dashboard.

The dashboard is accessible by going through this link http://localhost/projectX/index.php/dashboard

However, if I try to do it without index.php (http://localhost/projectX/dashboard) it says Not Found.

Here's what my .htaccess file looks like (the file is outside application folder and in root directory of projectX folder)

RewriteBase /projectX

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

Here's my config file :-

$config['base_url'] = "http://localhost/projectX/";
/*
|--------------------------------------------------------------------------
| Index File
|--------------------------------------------------------------------------
|
| Typically this will be your index.php file, unless you've renamed it to
| something else. If you are using mod_rewrite to remove the page set this
| variable so that it is blank.
|
*/
$config['index_page'] = '';

/*

What am I doing wrong?

4
  • If you are using ubuntu you should active rewrite mode "sudo a2enmod rewrite" Commented Jan 16, 2019 at 13:23
  • @sparshturkane I'm on a mac. Commented Jan 16, 2019 at 13:23
  • Have you restarted apache ? Commented Jan 16, 2019 at 13:30
  • Just did. Nothing changed Commented Jan 16, 2019 at 13:37

2 Answers 2

1

Check these rules:

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

And Change this also:

$config['uri_protocol'] = "AUTO"

//  Replace with

$config['uri_protocol'] = "REQUEST_URI" 

Source: https://www.codeigniter.com/userguide3/general/urls.html

Sign up to request clarification or add additional context in comments.

4 Comments

Try to keep .htaccess inside the root folder. It will work.
@NetStack Check updated answer and try to run again.
try to keep index.php and .htaccess in same folder location.
Check your Apache config file (httpd.conf) and check that your directory has AllowOverride option selected.
0

try this in your .htaccess file

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.