I have a problem....I removed index.php from url...So ma route is :
$route['default_controller'] = "pages/show/index";
$route['photo'] = "pages/show/photo";
$config['base_url'] = 'http://localhost/blogCI/';
If I write in browser : localhost/blogCI/photo doesn't work, but if I write localhost/blogCI/index.php/photo it's work...
I have a .htaccess in root:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
I use apache and mod rewrite is actived and in my config
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
Everything is normal but I don't understand where is the problem...Help me guys please!!!!!!!!!!!
Won't work in a subfolder.
Create virtual host if you need CI to be located in that folder or move it to www root.
Related
My site http://www.bishal.prtia.com/prT_base/ throw an 404 error while loading in the server.
It works perfectly in the localhost. I tried changing everything that mentioned in this forum like changing .htaccess to web.config and changing base url routing config etc but it still throws an error.
Check the following things once again:
Make sure your base_url is proper as per your website address, not localhost
Check routes.php file for default controller and make sure it is correct.
Make sure .htaccess looks like
RewriteEngine on
RewriteCond $1 !^(index\.php|assets|images|js|css|upload|favicon.png)
RewriteCond %(REQUEST_FILENAME) !-f
RewriteCond %(REQUEST_FILENAME) !-d
RewriteRule ^(.*)$ ./index.php/$1 [L]
Then check following thigs:
Config.php
$config['base_url'] = 'http://www.bishal.prtia.com/prT_base/';
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
Routes.php
$route['default_controller'] = 'your controller name (like welcome)';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;
Make sure php file name of controller start with capital letter like Welcome and also inside that file as well when inherit from CI_Controller
Function inside Welcome.php:
public function index()
{
$this->load->view('your view file');
}
Thanks
You need to do few steps.
Update base_url in config.php
Update RewriteBase in .htaccess
Set Permissions
if still not workable, add error_reporting(E_ALL) in index.php and see what it says
I also faced this error. I changed my .htaccess file [WORKED FOR ME] :-
.htaccess for Live Server :-
DirectoryIndex index.php
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|robots\.txt)
RewriteRule ^(.*)$ index.php?/$1 [L]
.htaccess for Localhost :-
RewriteEngine On
#RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.php/$1
http://localhost/codeigniter/index.php/user/main_page
how can you remove index.php from this url ?
Try this file. I use it in my projects
https://github.com/eborio/curso-de-codeigniter/tree/master/02-primeros-pasos
The answer is in the post that this question is ducplicated of.
This is the answer
Sean Vieira's answer:
If you are using Apache place a .htaccess file in your root web
directory containing the following:
RewriteEngine on
RewriteCond $1 !^(index\.php|[Javascript / CSS / Image root Folder name(s)]|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
Another good version is located here:
http://snipplr.com/view/5966/codeigniter-htaccess/
Try this:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
Replace:
$config['index_page'] = "index.php"
to
$config['index_page'] = ""
if it still not work try to replace:
$config['uri_protocol'] = "AUTO"
//replace with the below code
$config['uri_protocol'] = "REQUEST_URI"
for more details: http://w3code.in/2015/09/how-to-remove-index-php-file-from-codeigniter-url/ check this
I am running Apache 2.2.22 on Ubuntu 12.04.3 (Oracle VM on Windows 8.1).
Using the PHP phpinfo() function I see mod_rewrite in the apache2handler section under Loaded Modules, so mod_rewrite is enabled.
I made the following changes to my CI config file (application/config/config.php),
$config['index_page'] = 'index.php'; to: $config['index_page'] = '';
$config['uri_protocol'] = 'AUTO'; to: $config['uri_protocol'] = 'PATH_INFO';
I have tried numerous versions this(.htaccess file located in the root directory of CI ):
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
but have yet to get it to work.
What else am I missing here?
This worked!
RewriteEngine On
RewriteBase /testsite/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
Working on the assumption that your folder structure is something like... /var/www/html/testsite and your url is localhost/testsite, then the above rewrite rule will be looking for index.php in /var/www/html and not /var/www/html/testsite.
( /var/www/html will be the default document root. )
So in your equivalent folder of /var/www/html/testsite you can try using the following in your .htaccess file located in /var/www/html/testsite/. so you'd have /var/www/html/testsite/.htaccess with the code...
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]
All I have done is removed the leading / in the rewrite rule in the last line so it's not heading back to the default document root.
I am using CI 2.1.4 (trying to use) when I edit .htaccess to remove the index.php from my url it doesn't work. My project is inside a subfolder:
http://myserver.dev/project/
I've set the base_url removed the index.php from $config['index_page'] = '' and pasted the exact code form http://ellislab.com/codeigniter/user-guide/general/urls.html:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
Tried some solutions (some using RewriteBase) from stackoverflow.com fellows, but, it doesn't work.
How can I fix that?
I dont think it's because of the .htaccess, this works for me and not because of the subfolder either.
This is an example of the .htaccess I'm using :
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^/(index\.php|assets/|humans\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]
Set the right url in the base_url or this :
$config['base_url'] = 'http' . ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 's' : '')
.'://'.$_SERVER['HTTP_HOST'].str_replace('//','/',dirname($_SERVER['SCRIPT_NAME']).'/');
And obviously :
$config['index_page'] = '';
With this, it works for me...
I have a CodeIgniter install running in our root web directory that I copied into a subdirectory called /dev... I edited the config/config.php file to reflect the change so it is now like this:
$config['base_url'] = 'http://mysite.com/dev';
$config['sbase_url'] = 'https://mysite.com/dev';
$config['default_email'] = 'noreply#mysite.com';
$config['site_url'] = 'http://mysite.com/dev';
This is my .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
When I hover over any links on the site they are correct, for example the contact us page link reads www.mysite.com/dev/contact but when I click any of the links I get a 404 error...
Is there something common I am missing?
Enable FollowSymlinks & add a ./ in front of index.php in your RewriteRule:
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
# block hidden directories
RewriteRule "(^|/)\." - [F]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]
</IfModule>
Also, I would leave blank $config['base_url'] = ''; & use the base_url() url helper when constructing links instead, which makes moving environments easier (e.g. subdir'd dev & root-level production).
... and of course, insure that ModRewrite is enabled in your Apache config.