简体   繁体   English

如何使用PHP重定向到base_url之后的url

[英]How to use PHP to Redirect to an url after the base_url

I'm trying to use PHP to redirect to a page 5 secs after an action is done.我正在尝试使用 PHP 在操作完成后 5 秒重定向到页面。 I've searched up how to use header for this but want to get more info on incorporating base_url() into the code, so I won't need to change this script multiple times on different servers.我已经搜索了如何为此使用标头,但想要获得有关将 base_url() 合并到代码中的更多信息,因此我不需要在不同的服务器上多次更改此脚本。

Code:代码:

$url=base_url().'page_I_want_to_go_to'
header('Refresh: X; URL=$url');

This does redirect me to a link, but the url is not the url I was indicating with base and page I want to go to.这确实将我重定向到一个链接,但该 url 不是我用我想要访问的基础和页面指示的 url。

Edit to:编辑为:

$url=base_url().'page_I_want_to_go_to'
header('Refresh: 5; URL=' . $url);

Do you have something configured inside the config file.您是否在配置文件中配置了某些内容。 Check the configuration of the framework that uses.检查使用的框架的配置。 For example, in codeigniter the configuration file is in /application/config/config.php例如,在 codeigniter 中,配置文件在/application/config/config.php

$config['base_url'] = 'my_page';

Change the bottom line to "double quotes", PHP wont substitute variables that are in single quotes.将底线更改为“双引号”,PHP 不会替换单引号中的变量。

$url=base_url().'page_I_want_to_go_to'
header("Refresh: X; URL=$url");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM