Codeigniter error 404 on production after set_flashdata - codeigniter

I'm using CI on my project, when I moved it on production server, I saw the error "404 page not found" when calling $this->session->set_flashdata. This error is preserved when I requested any page until I cleared the cookies. This error repeats after call "set_flashdata" again.
function _set_success($message)
{
$this->session->set_flashdata('is_db_msg', 1);
$this->session->set_flashdata('db_msg', $message);;
}
$result = $this->page_model->edit_page($page_name, $this->_get_data_array());
$result ? $this->_set_success('OK') : $this->_set_error(DB_ERROR);
redirect(BASEURL.'admin/pages');
// server 404 (on any page) after redirect
BASEURL it's constant: DEFINE('http://mysite.com');
Also I'm using this .htaccess:
DirectoryIndex index.php
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www [NC]
RewriteRule ^(index\.php/?)?(.*[^/])/?$ http://mysite.com/$2 [L,R=301]
RewriteCond %{HTTP_HOST} ^www [NC]
RewriteRule ^$ http://mysite.com [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(index\.php/?)?(.+)/$ /$2 [L,R=301]
RewriteCond %{ENV:REDIRECT_FINISH} ^$
RewriteRule ^index\.php/(.*)$ $1 [L,R=301]
RewriteRule ^(main/index(/index)?|index(\.php)?)/?$ / [L,R=301]
RewriteRule ^([^/]*)/index/?$ $1 [L,R=301]
RewriteCond %{REQUEST_URI} ^(system|application).*
RewriteRule ^(.*)$ /index.php/$1 [L,E=FINISH:END]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L,E=FINISH:END]
Please, help and sorry for my bad english.

You should use following for redirecting:
redirect('admin/pages');
or
redirect(base_url().'index.php/admin/pages');
or
DEFINE('BASEURL','http://mysite.com')
redirect(BASEURL.'index.php/admin/pages');

Related

laravel is getting a folder as url .. https://domain-name/uploads/ckeditor

I am facing an issue that Laravel is getting my folder as a URL while in crawling. I have using redirection but still the error is present.
<IfModule mod_rewrite.c>
RewriteEngine On
# Removes index.php from ExpressionEngine URLs
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?url=$1 [PT,L]
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
</IfModule>
I have tried this i htaccess

how to redirect laravel website using .htaccess or bootstrap file change

how to redirect laravel website using .htaccess or bootstrap file change
I have a domain www.mydm.com/folder/public but maximum url says my.mydm.com how can i tell my domain my.mydm.com to hit is equal to www.mydm.com/folder/public laravel
Wrote this
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
RewriteRule /assets www.mydm.com/folder/public [R=301,L]
does not help me
Any idea please guide thanks in advance
Please guide
Can you try with this
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteEngine On
RewriteRule ^$ public/index.php [L]
RewriteRule ^((?!public/).*)$ public/$1 [L,NC]
step 1:
Rename File server.php INTO index.php
step 2:
Update .htaccess
Options -MultiViews -Indexes
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_URI} !(\.css|\.js|\.png|\.jpg|\.gif|robots\.txt)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^/public/
RewriteRule ^(css|js|images)/(.*)$ public/$1/$2 [L,NC]

way to remove "/home" just from my home page in codeigniter

I am new to Codeigniter.
I want my homepage to be set as "example.com" rather as "example.com/home" currently.
My routes.php is like this:
$route['default_controller'] = "home";
Everything is working fine, just need to know if there is a way to remove "/home" just from my home page. Everywhere else is fine.
.htaccess
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
In your .htaccess file use this rule:
RewriteRule ^(home(/index)?|index(\.php)?)/?$ / [L,R=301]
RewriteRule ^(.*)/index/?$ $1 [L,R=301]
In your case, maybe this could be solution. Try this way:
RewriteEngine on
RewriteBase /
RewriteRule ^(home(/index)?|index(\.php)?)/?$ / [L,R=301]
RewriteRule ^(.*)/index/?$ $1 [L,R=301]
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} ^www\.(.*)
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
php_value session.cookie_httponly 1
php_value session.cookie_secure 1
Just write in your .htaccess :
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
and
$route['default_controller'] = "home";
in your routes.php
and check
$config['base_url']='http://exemple.com/';
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
then example.com will show example.com/home controller but wont display the '/home' uri segment. It works fine for me

Mod_Rewrite Exclude a url (URI Exception)

I am using this mod-rewrite rule to redirect the just the homepage of my site to the /it/ sub-directory on the same site.
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RedirectMatch 301 ^/$ http://www.example.com/it/
However, I want to exempt this url from being redirected
http://www.example.com/?act=25
How can I write an exempt condition to do this?
Found a solution
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteCond %{QUERY_STRING} !^act=(.*)$ [NC]
RewriteRule ^$ http://www.example.com/it/
Oh, and RewriteCond does not work with RedirectMatch in case you didn't know (I didn't and wasted hrs because of it)

Using mod_rewrite with multiple Drupal installations

I have a website with Drupal installed in a subfolder /drupal. This instance needs to handle all URLs for the site, which it does successfully with the rules below:
RewriteEngine on
Options +FollowSymLinks
RewriteCond %{HTTP_HOST} !^131.216.164.200:10011$ [NC]
RewriteRule .* http://131.216.164.200:10011/ [L,R=301]
RewriteRule ^$ drupal/index.php [L]
RewriteCond %{DOCUMENT_ROOT}/drupal%{REQUEST_URI} -f
RewriteRule .* drupal/$0 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* drupal/index.php?q=$0 [QSA]
However, I now need to add another Drupal folder, /otherdrupal, which will handle only URLs beginning with /something1 or /something2. What I've tried is modifying the rules to this:
RewriteCond %{HTTP_HOST} !^131.216.164.200:10011$ [NC]
RewriteRule .* http://131.216.164.200:10011/ [L,R=301]
RewriteRule ^(something1|something2)$ otherdrupal/index.php [L]
RewriteRule ^$ drupal/index.php [L]
RewriteCond %{DOCUMENT_ROOT}/drupal%{REQUEST_URI} -f
RewriteRule .* drupal/$0 [L]
RewriteCond %{DOCUMENT_ROOT}/otherdrupal%{REQUEST_URI} -f
RewriteRule .* otherdrupal/$0 [L]
But mod_rewrite is not gonna make it that easy...
(P.S. I'm aware of Drupal's multi-site feature, but assume that the second Drupal instance may be any web application that handles URLs the same way as Drupal does, e.g. with a q URL parameter.)
I figured it out. My working .htaccess file:
RewriteEngine on
Options +FollowSymLinks
RewriteCond %{HTTP_HOST} !^131.216.164.200:10011$ [NC]
RewriteRule .* http://131.216.164.200:10011/ [L,R=301]
RewriteRule ^$ drupal/index.php [L]
RewriteCond %{REQUEST_URI} ^(/something1|/something2)
RewriteRule .* otherdrupal/index.php?r=$1 [L,QSA]
RewriteCond %{DOCUMENT_ROOT}/drupal%{REQUEST_URI} -f
RewriteRule .* drupal/$0 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* drupal/index.php?q=$0 [QSA]

Resources