谁能告诉我为什么我的重定向助手不能按我期望的方式工作?
我正在尝试重定向到主控制器的索引方法,但这需要我www.example.com/index/provider1/
当它应该路由到www.example.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} ^example.com/ttnf/
RewriteRule (.*) http://www.example.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
重定向()
网址助手
The redirect statement in code igniter sends the user to the specified web page using a redirect header statement.
该语句驻留在 URL 帮助程序中,该帮助程序通过以下方式加载:
$this->load->helper('url');
重定向函数加载函数调用的第一个参数中指定的本地 URI,并使用配置文件中指定的选项构建。
第二个参数允许开发者使用不同的HTTP命令来执行重定向“定位”或“刷新”。
根据 Code Igniter 文档:“定位速度更快,但在 Windows 服务器上有时可能会成为问题。”
Example:
if ($user_logged_in === FALSE)
{
redirect('/account/login', 'refresh');
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)