CodeIgniter Forums
.htaccess ERR_TOO_MANY_REDIRECTS - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: .htaccess ERR_TOO_MANY_REDIRECTS (/showthread.php?tid=62187)



.htaccess ERR_TOO_MANY_REDIRECTS - dilanwijerathne - 06-17-2015

I want to detect Internet explora 8 or lower version of Internet explora and redirect Internet explora agents to another view.
I tried to do that like this

RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} "MSIE [6-8]" [NC]
RewriteCond %{REQUEST_URI} !^/sample.html
RewriteRule .* /sample.html [R]

it does work but when I try to redirect it to a view inside codeIgnitor, it dooes not work and it gives
" ERR_TOO_MANY_REDIRECTS " Huh

then how can I perform this ?
my view is located in application/views/IEView.php

how can I redirect it properly ? Sad

Appreciate any help
Dilan


RE: .htaccess ERR_TOO_MANY_REDIRECTS - mwhitney - 06-17-2015

First, you should perform the redirect in .htaccess or CodeIgniter, not both.

Second, you need to redirect to a controller/method, not a view; or simply load a different view for the user agent rather than redirecting.

If you are redirecting, you need to make sure you aren't performing another redirect when the user comes into the site after being redirected. A redirect tells the browser to go to another URL, which means your application is going to start over again with the same user requesting the new URL.


RE: .htaccess ERR_TOO_MANY_REDIRECTS - dilanwijerathne - 06-17-2015

(06-17-2015, 07:36 AM)mwhitney Wrote: First, you should perform the redirect in .htaccess or CodeIgniter, not both.

Second, you need to redirect to a controller/method, not a view; or simply load a different view for the user agent rather than redirecting.

If you are redirecting, you need to make sure you aren't performing another redirect when the user comes into the site after being redirected. A redirect tells the browser to go to another URL, which means your application is going to start over again with the same user requesting the new URL.

Can you give me a sample ?


RE: .htaccess ERR_TOO_MANY_REDIRECTS - dilanwijerathne - 06-17-2015

(06-17-2015, 07:52 AM)dilanwijerathne Wrote:
(06-17-2015, 07:36 AM)mwhitney Wrote: First, you should perform the redirect in .htaccess or CodeIgniter, not both.

Second, you need to redirect to a controller/method, not a view; or simply load a different view for the user agent rather than redirecting.

If you are redirecting, you need to make sure you aren't performing another redirect when the user comes into the site after being redirected. A redirect tells the browser to go to another URL, which means your application is going to start over again with the same user requesting the new URL.

Can you give me a sample ?

I tried like this calling controller 


RewriteEngine on

RewriteCond $1 !^(index\.php|public|\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1


RewriteCond %{HTTP_USER_AGENT} "MSIE [6-8]" [NC]
RewriteRule .* /secPay/doc [R]


but it does not work 
it gives error like this 

This webpage has a redirect loop


ERR_TOO_MANY_REDIRECTS


how can I solve this ?



RE: .htaccess ERR_TOO_MANY_REDIRECTS - mwhitney - 06-18-2015

PHP Code:
$viewName 'nonIeView';
$this->load->library('user_agent');

if (
$this->agent->is_browser('Internet Explorer')) {
 
   // Does the version require a different view?
 
   // Note: this code is untested and should be replaced with whatever makes sense to you.
 
   $version $this->agent->version();
 
   if ($version !== '') {
 
       $version substr($version01);
 
       if (in_array($version, array('6''7''8'))) {
 
           $viewName 'IEView';
 
       }
 
   }
}

$this->load->view($viewName);