I have read multiple threads with people having a similar issue and none of the solutions seem to work for me. My site is hosted at http://localhost/mysite/.
I have a codeigniter site and am using XAMPP.
Anytime I want to access a page I have index.php in the url (http://localhost/mysite/index.php/newpage or http://localhost/mysite/index.php/anothernewpage)
Here is my .htaccess file
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
Here is my config file
$config['base_url'] = "http://localhost";
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
Here are my routes
$route['default_controller'] = 'welcome';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;
I have also uncommented the following line in my httpd.conf file (XAMPP)
LoadModule rewrite_module modules/mod_rewrite.so
If I try to access an area of the site without including the index.php (http://localhost/mysite/newpage)I get an error 404 The requested URL was not found on this server. I have to put the full url http://localhost/mysite/index.php/newpage. Can anyone help me figure out what is wrong with this setup?
CodePudding user response:
Your base url should be $config['base_url'] = "http://localhost/mysite";
CodePudding user response:
In the root in .htaccess (if not exists, create one):
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
in application/config/config.php
$config['base_url'] = ((isset($_SERVER['HTTPS']) && (strtolower($_SERVER['HTTPS']) || $_SERVER['HTTPS']==1)) ? "https" : "http")."://".$_SERVER['HTTP_HOST']."/";
In localhost (only localhost) add sitename after '/' in $config['base_url'];