【发布时间】:2016-01-08 03:37:28
【问题描述】:
由于我在任何地方都找不到这个问题的答案,所以问题来了。但在此之前,感谢任何回答/帮助的人。
index.php页面的伪代码为:
<html>
<head><script>
<?php
$links = parse_ini_file('links.ini');
if(isset($_GET['l']) && array_key_exists($_GET['l'], $links)){
$my_phpvar = $links[$_GET['l']];
}
else{
header('HTTP/1.0 404 Not Found');
echo 'Unknown link.';
}
?>
var myjsvar= <?php echo $my_phpvar; ?>
function go(){
document.cookie = "visited=; expires=Thu, 01 Jan 1970 00:00:00 GMT";
window.location.href = "myjsvar";
}
</script></head>
<body><a id="myA1" href="javascript:go();" target="_blank">Click</a></body>
</html>
很明显,在上面的代码中,myjsvar 来自 my_phpvar,而 my_phpvar 来自单独的文件 links。 ini(对不起,如果我让你感到无聊,因为这在代码中都很明显,但我不想错过任何可以提供帮助的人)
我在 index.php 所在目录的根目录下的 .htaccess 文件中添加了一些规则。已经添加的规则是
RewriteEngine On
RewriteCond $1 !^(index\.php)
RewriteRule ^(.*)$ index.php?l=$1 [L]
links.ini 文件如下所示:
ex = https://www.example.com
所以 主要问题 是:当我浏览 URL http://www.yoursite.com/short/index.php?l=ex 时,点击按钮启动 函数 go() ,它不会将我带到网站 https://www.example.com
再次感谢任何解决/帮助解决问题的人。
【问题讨论】:
标签: javascript php html .htaccess