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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/visual-studio-2010/4.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
使用htaccess添加\时如何在php中创建链接_Php_.htaccess_Mod Rewrite - Fatal编程技术网

使用htaccess添加\时如何在php中创建链接

使用htaccess添加\时如何在php中创建链接,php,.htaccess,mod-rewrite,Php,.htaccess,Mod Rewrite,我已经回答了一个关于如何在我的url中添加/并在内部重定向它的问题。我得到的答案很有效,但我偶然发现了一个新问题 恢复密码时,您将被迫更改密码: if (logged_in() === true) { if ($current_file !== 'changepassword.php' && $user_data['password_recover'] == 1) { header('Location: changepassword.php?force')

我已经回答了一个关于如何在我的url中添加/并在内部重定向它的问题。我得到的答案很有效,但我偶然发现了一个新问题

恢复密码时,您将被迫更改密码:

if (logged_in() === true) {
    if ($current_file !== 'changepassword.php' && $user_data['password_recover'] == 1) {
        header('Location: changepassword.php?force');
        exit();
    }
}
当您在索引页面上,被迫更改密码时,URL会从mysite.com//index/转到mysite.com//index/changepassword/?force,这显然是不存在的

当我使用?force without changepassword.php时,它会得到一个“this page has this page has redirect loop”警告,尽管它确实适用于其他事情,如?success

Base href=“/”也没有任何效果


有什么想法吗?

我猜你的问题是你用
/
替换了“终止”
.php
。所以
/index.php
变成了
/index/
。如果您现在重定向到
changepassword.php?force
,您将得到
/index/changepassword/?force

但由于脚本
changepassword.php
可能与
index.php
位于同一级别,因此必须使用主机相对重定向,而不是路径相对重定向:

header('Location: /changepassword.php?force');

请注意位置目标中的前导
/

非常简单,但我没有找到它。非常感谢你