CodeIgniter로 리디렉션
내 리디렉션 도우미가 예상대로 작동하지 않는 이유를 아는 사람이 있습니까? 내 메인 컨트롤러의 색인 방법에 리디렉션하기 위해 노력하고있어,하지만 그것은 나를 소요 www.mysite.com/index/provider1/
때까지 경로를해야한다 www.mysite.com/provider1
. 누구에게도 이치가 있습니까? 나는 그것이 문제라고 생각하지 않지만 구성의 색인 페이지를 공백으로 설정했습니다. 누구든지이 문제를 해결하는 방법에 대한 조언이 있습니까? 미리 감사드립니다!
컨트롤러 :
if($provider == '') {
redirect('/index/provider1/', 'location');
}
.htaccess :
RewriteEngine on
RewriteCond %{REQUEST_URI} !^(index\.php|files|images|js|css|robots\.txt|favicon\.ico)
RewriteCond %{HTTP_HOST} ^mysite.com/ttnf/
RewriteRule (.*) http://www.mysite.com/ttnf/$1 [R=301,L]
RewriteBase /ttnf/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
php_flag display_errors On
redirect ()
URL 도우미
코드 이그나이터의 리디렉션 문은 리디렉션 헤더 문을 사용하여 사용자를 지정된 웹 페이지로 보냅니다.
이 문은 다음과 같은 방식으로로드되는 URL 도우미에 있습니다.
$this->load->helper('url');
리디렉션 함수는 함수 호출의 첫 번째 매개 변수에 지정되고 구성 파일에 지정된 옵션을 사용하여 빌드 된 로컬 URI를로드합니다.
두 번째 매개 변수를 사용하면 개발자가 다른 HTTP 명령을 사용하여 "위치"또는 "새로 고침"리디렉션을 수행 할 수 있습니다.
Code Igniter 문서에 따르면 "위치는 더 빠르지 만 Windows 서버에서는 때때로 문제가 될 수 있습니다."
예:
if ($user_logged_in === FALSE)
{
redirect('/account/login', 'refresh');
}
디렉토리 구조가 이와 같으면
site
application
controller
folder_1
first_controller.php
second_controller.php
folder_2
first_controller.php
second_controller.php
작업중인 동일한 컨트롤러에서 리디렉션하려면 다음 코드를 작성하십시오.
$this->load->helper('url');
if ($some_value === FALSE/TRUE) //You may give 0/1 as well,its up to your logic
{
redirect('same_controller/method', 'refresh');
}
다른 컨트롤로 리디렉션하려면 다음 코드를 사용하십시오.
$this->load->helper('url');
if ($some_value === FALSE/TRUE) //You may give 0/1 as well,its up to your logic
{
redirect('folder_name/any_controller_name/method', 'refresh');
}
이전 위치 또는 마지막 요청을 리디렉션하려면 user_agent
라이브러리 를 포함해야 합니다.
$this->load->library('user_agent');
그런 다음 사용중인 함수에서 마지막으로 사용합니다.
redirect($this->agent->referrer());
그것은 나를 위해 일하고 있습니다.
first, you need to load URL helper like this type or you can upload within autoload.php file:
$this->load->helper('url');
if (!$user_logged_in)
{
redirect('/account/login', 'refresh');
}
Here is .htacess file that hide index file
#RewriteEngine on
#RewriteCond $1 !^(index\.php|images|robots\.txt)
#RewriteRule ^(.*)$ /index.php/$1 [L]
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# Removes index.php from ExpressionEngine URLs
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteCond %{REQUEST_URI} !/system/.* [NC]
RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]
# Directs all EE web requests through the site index file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
참고URL : https://stackoverflow.com/questions/723883/redirect-with-codeigniter
'UFO ET IT' 카테고리의 다른 글
localhost 및 0.0.0.0 용 IPV6은 무엇입니까? (0) | 2020.12.10 |
---|---|
각도 2 formarray에서 모든 항목을 제거 (0) | 2020.12.10 |
Cocoa에서 현재 날짜를 얻는 방법 (0) | 2020.12.10 |
Postgresql 서버의 postgres라는 기본 데이터베이스 (0) | 2020.12.10 |
MimeType을 알 수없는 파일에 대한 ACTION_VIEW 인 텐트 (0) | 2020.12.10 |