Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/244.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.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 如何在访问主页时将用户重定向到特定URL?_Php_.htaccess_Codeigniter - Fatal编程技术网

Php 如何在访问主页时将用户重定向到特定URL?

Php 如何在访问主页时将用户重定向到特定URL?,php,.htaccess,codeigniter,Php,.htaccess,Codeigniter,我想在用户访问主页时重定向用户 因此,如果他访问example.com,当然如果有http、https、www或来自谷歌的访问,他应该被重定向到example.com/#element 我不能使用: header() 因为这个网站是用CodeIgniter构建的,我无法获得正确的php文件 要么: window.location 因为我不想依赖客户端 $this->load->helper('url'); redirect('/controller/function/',

我想在用户访问主页时重定向用户

因此,如果他访问example.com,当然如果有http、https、www或来自谷歌的访问,他应该被重定向到
example.com/#element

我不能使用:

header()
因为这个网站是用CodeIgniter构建的,我无法获得正确的php文件

要么:

window.location
因为我不想依赖客户端

$this->load->helper('url');   
redirect('/controller/function/', 'refresh');

在家庭控制器的索引函数中使用此代码

使用JavaScript(location.hash是您要使用的属性),在这个特定的星座中,其他一切都将导致麻烦。虽然服务器端重定向到带有散列部分的URL是可能的,但这里您将从
/
重定向到
/#元素
——但是如果这使客户端向服务器发出实际的新请求,您将陷入无休止的循环,因为大多数客户端不会将URL的散列部分发送到服务器,因此,您无法将此请求与前一个请求区分开来。那么.htaccess呢?这会导致ta出现问题吗?这也是服务器端重定向,所以-同样的问题。问题是什么?例如,它不能检查是否存在吗?或者直接转到几天前的那个URL,但我想你要找的是。