Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php CodeIgniter htaccess重定向url问题_Php_.htaccess_Codeigniter_Redirect_Url Rewriting - Fatal编程技术网

Php CodeIgniter htaccess重定向url问题

Php CodeIgniter htaccess重定向url问题,php,.htaccess,codeigniter,redirect,url-rewriting,Php,.htaccess,Codeigniter,Redirect,Url Rewriting,我想为我的网站“好网址”。我正在考虑使用.htaccess,我已经尝试了许多版本 现在我有这个: IfModule mod_rewrite.c> Options +FollowSymlinks RewriteEngine On # !IMPORTANT! Set your RewriteBase here and don't forget trailing and leading # slashes. # If your page resides at # http://www.exa

我想为我的网站“好网址”。我正在考虑使用
.htaccess
,我已经尝试了许多版本

现在我有这个:

IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
# !IMPORTANT! Set your RewriteBase here and don't forget trailing and leading
#  slashes.
# If your page resides at
#  http://www.example.com/mypage/test1
# then use
# RewriteBase /mysite
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>
我的.htaccess文件位于我的应用程序根目录中。

我需要登录管理员页面,因此
localhost/mysite/admin
是我的管理员站点url

public function index()
    {
    //  $this->session->unset_userdata('logged_in'); session_destroy();
        $data['sitename']="Varkocs Old Pub";
         if($this->session->userdata('logged_in'))
           {
             $session_data = $this->session->userdata('logged_in');
             $data['username'] = $session_data['username'];
             $this->load->view('admin/home_view', $data);
       }
       else
       {
         //If no session, redirect to login page
         //redirect('login', 'refresh');


            $this->load->helper(array('form', 'url'));

            $this->load->view('admin/login',$data);
       }

}
public function logout()
 {
   $this->session->unset_userdata('logged_in');
   session_destroy();
   redirect('', 'refresh');
 }
这是我的管理员控制器。如果登录我加载
home\u视图
,则在此处尝试,否则将加载
登录
视图

<div id="" class="container-fluid ">
    <div id="" class="row">
        <div id="" class="col-md-4 text-center admin_container">

          <h2><?php echo $sitename;?><h4>belépés az admin felületre</h4></h2>

           <?php  echo validation_errors('<p class="bg-danger">','</p>');?>

           <form action="verifylogin" method="post" accept-charset="utf-8">
            <div class="form-group">
             <label for="username">Username:</label>
             <input class="form-control" placeholder="" type="text" size="20" id="username" name="username"/>
            </div>
            <div class="form-group">
             <label for="password">Password:</label>
             <input class="form-control" placeholder="password" type="password" size="20" id="passowrd" name="password"/>
            </div>
             <input class="btn btn-warning btn-lg btn-block" type="submit" value="Login"/>
           </form>
        </div>
    </div>
因为它返回了错误的URL

所以我写HTML:

<form action="verifylogin" method="post" accept-charset="utf-8">

我已经尝试了很多方法来解决这个问题,但都失败了。

Codeigniter文档对重定向功能做了如下说明:

In order for this function to work it must be used before anything is outputted to the 
browser since it utilizes server headers.

这条规则可能很难遵循。在开始PHP标记之前的空格或行尾将已经打断它

我的问题是重定向//转到专用区域重定向('admin','refresh');}我设置了基本url:localhost/mysite,我想转到localhost/mysite/admin controller。我能做什么?对不起,当你说重定向不起作用时,我以为它是空白页。如果它导致错误的页面,您可能需要将基本url调整为绝对url:
$config['base\u url']='http://localhost/mysite/';
<form action="verifylogin" method="post" accept-charset="utf-8">
  $this->load->helper(array('form', 'url'));
   if($this->form_validation->run() == FALSE)
   {
     //Field validation failed.  User redirected to login page
    $data['sitename']="Varkocs Old Pub";

     $this->load->view('admin/login',$data);

   }
   else
   {
     //Go to private area
     redirect('admin', 'refresh');

     }
In order for this function to work it must be used before anything is outputted to the 
browser since it utilizes server headers.