So, today I upgrade PHP and apache on my server to version PHP 5.4 and Apache 2.4.
And then I noticed on one domain using older version of codeigniter (I've try to echo CI_VERSION but it shows nothing) is showing error 404 on the root domain. But typing domain.com/home works fine. (home is my default controller). Typing any other controller also working fine. But domain.com shown error 404.
.htaccess
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ index.php/$1 [L]
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
#This last condition enables access to the images and css folders, and the robots.txt file
RewriteCond $1 !^(index\.php|apc\.php|assets|nivo-slider|hr|stm|elearning|docs|adminer|favicon\.ico|file|flash|tinymce|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
ErrorDocument 404 /application/errors/404.php
</IfModule>
config.php
$config['base_url'] = "http://".$_SERVER['HTTP_HOST'];
$config['index_page'] = "";
$config['uri_protocol'] = "AUTO";
routes.php
$route["default_controller"] = "home";
$route["error_controller"] = "error";
$route['scaffolding_trigger'] = "";
I've trying change uri_protocol to QUERY_STRING & REQUEST_URI but still not working.
I managed to solve this problem by adding DirectoryIndex home on my .htaccess.
Related
I have this wildcard route:
$route['izvlacenje-2022/(:any)']['GET'] = 'WinnersController/draw_screen/$1';
that works fine locally, but not on the server in the staging sub-folder where it gives me 404 error:
http://project.localhost/izvlacenje-2022/renovate // works fine locally
https://our-domain/staging/izvlacenje-2022/renovate // does not work in staging folder, gives 404
Other, non wildcard routes work fine. For example:
$route['intro']['GET'] = 'LandingsController/index';
https://our-domain/staging/intro // works fine
httacces:
DirectoryIndex index.php
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /staging
RewriteCond $1 !^(index\.php|resources|gallery|json|slider|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 index.php
</IfModule>
Also, in the config file I set the index_page value to blank, but it does not work either way:
$config['index_page'] = '';
I have some problem. In development I'm using php 7 and my website work well. But in production it using php 5.4 and I have problem in removing index.php. My website hosted in subfolder just like myhost/mywebsitefolder.
The problem is when using url function. example, when I accesing 'dashboard' page it will redirect to 'login' page and the url is like myhost/mywebsitefolder/login and it return 404 page not found. When I add index.php before login (myhost/mywebsitefolder/index.php/login) it work well but I must replace all of my url by adding index.php. Are there any solution. My .htaccess is just like this.
RewriteEngine on
RewriteBase /mywebsitefolder/
RewriteCond $1 !^(index.php|resources|gallery|json|slider|robots.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
Try with a slash before the dots, like:
DirectoryIndex index.php
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /mywebsitefolder
RewriteCond $1 !^(index\.php|resources|gallery|json|slider|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 index.php
</IfModule>
And in application/config/config.php and clear the index page config value:
// Old
$config['index_page'] = "index.php";
// New
$config['index_page'] = "";
Sometimes you need to enable it the rewrite module, run "apache2 enable module rewrite":
sudo a2enmod rewrite
You need to restart the webserver to apply the changes:
sudo service apache2 restart
Hope it works!
If no, there is others threads with the same problem,you can take a look:
- Remove index.php from codeigniter in subfolder
- Remove index.php from Codeigniter URL in subfolder with Wordpress in root
- Using htaccess to remove codeigniter index.php in a subdirectory
I get a error called "Your application folder path does not appear to be set correctly. Please open the following file and correct this: index.php". I use the site within a folder in main domain. My .htaccess file is as follows, if required.
<IfModule mod_rewrite.c>
############################################
## enable rewrites
# For security reasons, Option followsymlinks cannot be overridden.
# Options +FollowSymLinks
Options +SymLinksIfOwnerMatch
RewriteEngine on
############################################
## you can put here your magento root folder
## path relative to web root
############################################
## workaround for HTTP authorization
## in CGI environment
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
############################################
## always send 404 on missing files in these folders
RewriteCond %{REQUEST_URI} !^/(media|skin|js)/
############################################
## never rewrite for existing files, directories and links
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
############################################
## rewrite everything else to index.php
RewriteRule .* index.php [L]
</IfModule>
<IfModule mod_security.c>
# Turn off mod_security filtering. SMF is a big boy, it does not need its hands held.
SecFilterEngine Off
# The below probably isn't needed, but better safe than sorry.
SecFilterScanPOST Off
</IfModule>
You should post also your 'config' file, usually this come from a base_url or something messing up. My working site with CI uses:
$config['base_url'] = 'http://yourUrl.com/';
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
$config['url_suffix'] = '';
The .htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
#Add www.
RewriteCond %{HTTP_HOST} ^www.yourUrl.com [NC]
RewriteRule ^(.*)$ http://.yourUrl.com/$1 [L,R=301]
RewriteCond %{REQUEST_URI} ^core.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
And all works fine. You could check with your own config/htaccess file.
From here: Your system folder path does not appear to be set correctly. Please open the following file and correct this: index.php and CodeIgniter CLI giving system_path error "path does not appear to be set correctly."
The solution was to leave the $system_path blank...
$system_path = '';
you can try this instead:
$system_path = './system';
Some people also solved this with setting permissions to CI folder:
set the project folder permission to 755. Eg. sudo chmod 755 /var/www/myCIproject/
And last, for shared servers/folders:
https://serverfault.com/questions/371739/putting-folders-above-public-html-in-a-shared-hosting-environment
You'll notice in codeIgniter that there is a 'system' directory.
Navigate to your index.php file and go to $system_path and set it to that that path.
I noticed this today when I moved my index file from the codeIgniter directory into the root. You will also find that it will follow up with the applications directory. I found my directories in the same location (codeIgniter root). Once I replaced the path it worked well.
I'm really starting to regret buying a domain at One.com
I have a simple CI project set up that works perfectly on localhost, but one.com isn't my friend. I can't seem to get mod_rewrite working. I don't even bother contacting support, because I'm getting the feeling that anyone who needs more than an index page isn't welcome there.
This is my .htaccess file
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /luc/
#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#‘system’ can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$1 [L]
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn’t true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#This last condition enables access to the images and css folders, and the robots.txt file
#Submitted by Michael Radlmaier (mradlmaier)
RewriteCond $1 !^(index\.php|img|js|UberGallery|robots\.txt|css)
RewriteRule ^(.*)$ index.php?$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
# If we don’t have mod_rewrite installed, all 404’s
# can be sent to index.php, and everything works as normal.
# Submitted by: ElliotHaughin
ErrorDocument 404 /index.php
</IfModule>
And in CI config:
$config['base_url'] = '';//I have tried the full URI.
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO'; //I have tried REQUEST_URI as well.
luc is a subdomein of my domain, hence the RewriteBase in .htaccess.
In all my subfolders, I have an .htaccess file with deny from all.
This seems to be a one.com specific issue, so I hope there's someone experienced enough to spot an error in my setup.
What am I doing wrong?
My web application doesn't work without index.php in URL. It has been working in my previous Laptop (OS: Ubuntu 10.10). In my new laptop, in OS Fedora 16 it doesn't work. I did all the checking like .htaccess, cofig.php etc. Other application rather than CodeIgniter framework like PHPMyAdmin, work fine. Following is my .htaccess code.
# Options
Options -Multiviews
Options +FollowSymLinks
#Enable mod rewrite
RewriteEngine On
#the location of the root of your site
#if writing for subdirectories, you would enter /subdirectory
RewriteBase /barj
#Removes access to CodeIgniter system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#This last condition enables access to the images and css
#folders, and the robots.txt file
RewriteCond $1 !^(index\.php|images|robots\.txt|css)
RewriteRule ^(.*)$ index.php?/$1 [L]
in the config.php, I have the following conf
$config['index_page'] = "";
$config['REQUEST_URI'] = "AUTO";
Please give me any idea to resolve the issue.
Please check in appache configuration file that mod_rewrite module is enable or not.
You can check it by following command.
echo phpinfo();
If it is not enabled, enable it.
First try out this minimal code. It is working fine for me.
# Customized error messages.
ErrorDocument 404 /index.php
# Set the default handler.
DirectoryIndex index.php
# Various rewrite rules.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
</IfModule>