Codeigniter htaccess started problem suddenly even when no changes were made to any files. I can access
www.mysite.com/index.php/controller/method
but when I access
www.mysite.com/controller/method
it gives a general 404, not a codeigniter 404. Any help is appreciated. The site is down.
Here is my present htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
#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|images|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>
In this case i'm 100% sure your mod_rewrite is not working properly.Also make sure your .htacess file is in your root directory. A have this one working properly on my server may be this will help you :-
# rewrite rules
RewriteEngine On
# ditch index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]
Related
Can someone help me,
My site was working fine in staging server and I moved the site live server where I am getting HTTP ERROR 500.
My htaccess file is
<IfModule mod_rewrite.c>
RewriteEngine On
#RewriteBase /
#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]
#When your application folder isn't in the system folder
#This snippet prevents user access to the application folder
#Submitted by: Fabdrol
#Rename 'application' to your applications folder name.
RewriteCond %{REQUEST_URI} ^application.*
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]
</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>
The same htaccess file was there in both the servers. mod_rewrite was enabled and everything was fine from server side. Can someone help me what can be the issue
Not exactly an answer but too large for a comment:
switch (ENVIRONMENT) {
case 'development':
error_reporting(~E_DEPRECATED);
ini_set('display_errors', 1);
break;
case 'testing':
case 'production':
error_reporting(~E_DEPRECATED);
ini_set('display_errors', 1);
break;
default:
header('HTTP/1.1 503 Service Unavailable.', TRUE, 503);
echo 'The application environment is not set correctly.';
exit(1); // EXIT_ERROR
}
Change production to have the same error_reporting as development so you will get the errors instead of seeing a generic 500 page.
I don't believe you .htaccess file is at fault here as you wouuld get a 400 rather than a 500 (internal server error).
you can try this:
upload htaccess file in root
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
Options -Indexes
RewriteCond %{REQUEST_URI} ^system.*
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>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
Hi all I have the normal htaccess file for codeigniter and I want to 301 one url to another
I've had to obfuscate the links to be able to post :(
ie h2tp://www domain com/controller/method/value1
->h2tp://www domain com/controller/method/value2
but I'm having a hell of a time...
Here's the htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^(home(/index)?)/?$ / [L,R=301]
RewriteRule ^(.*)/index/?$ $1 [L,R=301]
#Removes trailing slashes
#had to remove ajaxquery search else it fails
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(search/ajaxsearch)
RewriteRule ^(.+)/$ $1 [L,R=301]
#Rewrite all non-www to www based filenames
#should get rid of any canonical issues
RewriteCond %{HTTP_HOST} ^domain\.es [NC]
RewriteRule ^(.*)$ http://www.domain\.es/$1 [R=301,L]
#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
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>[/code][/quote]
If I put
Redirect 301 /controller/method/value1 h2tp://www domain com/controller/method/value2
I get this
h2tp://www domain com/controller/method/value2?controller/method/value1
I've been hours on this now, it's killing me :)
Due to my complete lack of knowledge on htaccess I was trying to add the 301 redirects below these lines.
#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]
All checks had been run by then and the [L] flag was stopping anymore checks being run.
so when I posted a normal 301 redirect above the following lines it worked.
#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]
My htaccess right now:
# Use PHP 5.3
AddType application/x-httpd-php53 .php
RewriteEngine On
RewriteBase /
#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
RewriteRule ^(.*)$ index.php?/$1 [L]
# 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
I need to do a rule, that if somebody type http://www.mypage.com/blog/blablatitle
it redirects him to http://mypage.com/blog/blablatitle
and the same for the frontpage and all pages.
I am using CodeIgniter, but I think this is not so important when dealing with htaccess.
This suggested solution is not working well in CodeIgniter:
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
Because it adds index.php in the address e.g.: when I type:
http://www.mypage.com/blog/blablatitle
it redirects me to:
http://mypage.com/index.php?/blog/blablatitle
And I need:
http://mypage.com/blog/blablatitle
Without this rule it is ok (without index,php) e.g.: http://mypage.com/blog/blablatitle
So, any advice how to improve this redirect rule som index.php doesn't appear in the redirected link?
SOLVED! ;) You need to put it right after
RewriteBase /
Try this please:
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^index.php(.*)$ http://%1/$1 [R=301,L]
I am using codeigniter and below is my htaccess file. However, i want a single directory to be accessable outside of the codeigniter app via my domain.com/directory. the other directory is a forum not related to codeigniter. how would i set up a rule in htaccess? i dont have access to http.conf
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
#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]
#When your application folder isn't in the system folder
#This snippet prevents user access to the application folder
#Submitted by: Fabdrol
#Rename 'application' to your applications folder name.
RewriteCond %{REQUEST_URI} ^application.*
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]
</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>
This should already work. RewriteCond %{REQUEST_FILENAME} !-d tells mod_rewrite to ignore actual directories, and RewriteCond %{REQUEST_FILENAME} !-f tells it to ignore actual files.
I use this to exclude any folder from being parsed to codeigniter framework as a controller.
So www.domain.com/images/ would run as normal folder, etc. There you can put your individual directives of htaccess. Best of luck!
RewriteCond $1 !^(folders_to_exclude_from_CI|images|css|assets|resources|robots\.txt)
I'm developing a site on my localhost (Usbwebserver application). I'm using CodeIgniter framework:
url is "http://localhost/daniel/index.php"
with the following options:
config/routs:
$route['default_controller'] = "site";
config/config:
$config['base_url'] = "http://localhost/daniel";
$config['index_page'] = "";
$config['uri_protocol'] = "REQUEST_URI";
I've tried the following .htaccess code:
RewriteEngine On
RewriteBase /
#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
RewriteRule ^(.*)$ index.php?/$1 [L]
# 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
I want to remove index.php and to load my default controller with http://localhost/daniel.
Any suggestions?
Try:
RewriteRule ^(.*)$ /daniel/index.php?/$1 [L]
I used the hataccess from the codigniter wiki(the same that I had above):
RewriteEngine On
RewriteBase /
# Removes the "/" at the end
RewriteRule (.+)/$ /$1 [L,R]
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ daniel/index.php?/$1 [L]
# 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
With all the same option, only $config['uri_protocol'] = "AUTO"(instead of URI_PROTOCOL) and somehow it began to work (and I have the aplication folder outside of the system folder)
Thank You all who kindly replied me!