Asked  1 Year ago    Answers:  5   Viewed   16 times

I am working on a custom built CMS with codeIgniter. It works flawlessly in my localhost and on a account at bluehost. Now I have uploaded the site to ipage i get a strange error

0<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>302 Found</title>
</head><body>
<h1>Found</h1>
<p>The document has moved <a href="http://igncms.safaapps.com/admin/login">here</a>.</p>
<p>Additionally, a 302 Found
error was encountered while trying to use an ErrorDocument to handle the request.</p>
</body></html>
HTTP/1.1 200 OK
Date: Sat, 18 May 2013 15:08:04 GMT
Content-Type: text/html
Content-Length: 3897
Connection: keep-alive
Server: Apache/2
X-Powered-By: PHP/5.2.17
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache


<!DOCTYPE html>
<!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]>         <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
        <title>Lazy Admin | Login</title>
        <meta name="description" content=""/>
        <meta name="viewport" content="width=device-width"/>

        <link rel="stylesheet" href="http://igncms.safaapps.com/css/admin/bootstrap.min.css"/>

        <link rel="stylesheet" href="http://igncms.safaapps.com/css/admin/bootstrap-responsive.min.css"/>
        <link rel="stylesheet" href="http://igncms.s

This is what exactly i see, I notice there is a 0 at the beginning of the output. I am not sure where to start.

More interesting is that it happens only certain times, i havent figured out when but its randomly appearing followed by some sort of request (for example form submit, redirect etc.) And it just disappears on a page refresh.

Its becoming a major head ache cz i have to upload 30+ sites to the ipage host. I have no clue where do i start to solve the problem.

NOTES:

url: http://igncms.safaapps.com/ My url is directed to /igncms/

htaccess of the cms folder -

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

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>

Route config of codeIgniter

$route['default_controller'] = "home";
$route['admin'] = "admin/dashboard";
$route['404_override'] = '';

note that dashboard controller which is located in application/controller/admin/dashboard.php ( a folder within controller folder) has a route .

I have narrowed down that the problem is caused by htaccess. Can anyone indicate me to a proper htaccess declaration to hide index.php from CI 2.1.2?

Ask me and i will provide all information . I need this sorted out ASAP

 Answers

1

My problem was finally solved by the following settings

This one was new-

/*config.php*/ 

$config['index_page'] = ''; 
$config['uri_protocol'] = 'REQUEST_URI'; 


/*routes.php*/ 
$route['default_controller'] = "home"; 
$route[''] = "home/index"; 
$route['admin'] = "admin/dashboard"; 
$route['home'] = "home/index"; 
$route['404_override'] = ''; 



/*min htaccess*/ 
<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase / 
RewriteRule ^index.php$ - [L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . /index.php [L] 
</IfModule>
Saturday, May 29, 2021
 
Lorav
 
3

You can use either, but the proper statuscode to use for redirect-after-post is 303.

The confusion has a historical explanation. Originally, 302 specified that the browser mustn't change the method of the redirected request. This makes it unfit for redirect-after-post, where you want the browser to issue a GET request. However, all browsers seems to misinterpret the specs and always issue a GET request. In order to clear up the ambiguity HTTP/1.1 specified two new codes: 303 and 307. 303 essentially specifies the de-facto interpretation of 302, while 307 specifies the original specification of 302. So in practice 302 and 303 are interchangeable, and in theory 302 and 307 are.

If you really care about compatibility, 302 is a safer bet than 303, since HTTP/1.0 agents may not understand 303, but all modern browsers speak HTTP/1.1, so it isn't a real issue. I would recommend using 303, since that's the most correct thing to do.

On a side-note; The Location field should be a full URL. In practice it doesn't matter - browsers are forgiving - but if you care about the specs, that's the proper thing to do.

Thursday, April 1, 2021
 
mistero
 
2

That is a problem indeed. Because google will now think the 404.aspx page does not exist and will think the non-existing item is temporarily redirected.

I came up with a solution for this and blogged about it here.

What it does basically is determine that the item is non-existing (through a pipeline processor), then retrieve the contents of the 404 page by requesting it using a WebRequest and return that contents to the browser with a 404 status code.

Wednesday, August 4, 2021
 
4

I solved this way:

Add followRedirects: false and validateStatus: (status) { return status < 500;} to the request. Like this:

var response = await Dio().post("http://myurl",
    data: requestBody,
    options: Options(
        followRedirects: false,
        validateStatus: (status) { return status < 500; }
    ),
);

This way you can get from the 302 every headers and other.

Thursday, August 5, 2021
 
4

With Redirect, you need to send a valid URI. In your case, if you want to return only the relative URI, you must tell it to URI class:

public IHttpActionResult Get()
{
    return Redirect(new Uri("/assets/images/avatars/profile.jpg", UriKind.Relative));
}
Friday, December 17, 2021
 
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :