返回 link 但不使用历史记录
back link but not use history
如何恢复 href 但不使用历史记录
我试着写这个
config.php
$config['base_url'] = 'http://'.$_SERVER['HTTP_HOST'].'/webapp/';
并在 index.php
(我不知道要替换:
else{ die("wrong password <a href=\"javascript:history.back()\">back</a>");
最终目标是
index.php 是表单登录
如果没问题,那么下一页。
如果错了那么我想创建 link 回到 http://localhost/webapp
不是 http://localhost/webapp/index.php 或其他历史记录 url
die("wrong password <a href=\"" . $_SERVER['HTTP_REFERER'] . ".'/webapp/'">back</a>");
有一些选项可供选择,每个选项都有 缺点
基础URL
您可以使用 config.php
中定义的基数 URL
die('wrong password <a href="'.$config['base_url'].'">back</a>'); // repalce `"` with `'` to remove `\`; this a preference
这似乎是最好的选择,但是,浏览器再次请求 $config['base_url']
。与 back
选项不同,后者将后退一步(并保留提交前的所有字段(输入))
历史API
else{ die('wrong password <a href="javascript:history.go(-1)">back</a>');
这可能有效也可能无效,这取决于某些条件,例如,历史记录中有一组以前的页面。
这就是你想要的:
die("wrong password <a href=\""
. substr( $_SERVER['HTTP_REFERER'], 0, strrpos( $_SERVER['HTTP_REFERER'], '/' ) )
. "\">back</a>");
编辑:
这会将您送回 http://localhost/webapp not http://localhost/webapp/index.php
如何恢复 href 但不使用历史记录
我试着写这个 config.php
$config['base_url'] = 'http://'.$_SERVER['HTTP_HOST'].'/webapp/';
并在 index.php (我不知道要替换:
else{ die("wrong password <a href=\"javascript:history.back()\">back</a>");
最终目标是 index.php 是表单登录 如果没问题,那么下一页。 如果错了那么我想创建 link 回到 http://localhost/webapp 不是 http://localhost/webapp/index.php 或其他历史记录 url
die("wrong password <a href=\"" . $_SERVER['HTTP_REFERER'] . ".'/webapp/'">back</a>");
有一些选项可供选择,每个选项都有 缺点
基础URL
您可以使用 config.php
die('wrong password <a href="'.$config['base_url'].'">back</a>'); // repalce `"` with `'` to remove `\`; this a preference
这似乎是最好的选择,但是,浏览器再次请求 $config['base_url']
。与 back
选项不同,后者将后退一步(并保留提交前的所有字段(输入))
历史API
else{ die('wrong password <a href="javascript:history.go(-1)">back</a>');
这可能有效也可能无效,这取决于某些条件,例如,历史记录中有一组以前的页面。
这就是你想要的:
die("wrong password <a href=\""
. substr( $_SERVER['HTTP_REFERER'], 0, strrpos( $_SERVER['HTTP_REFERER'], '/' ) )
. "\">back</a>");
编辑: 这会将您送回 http://localhost/webapp not http://localhost/webapp/index.php