【发布时间】:2023-04-05 17:31:01
【问题描述】:
我的 htaccess:
RewriteEngine On
RewriteCond $1 !^(index\.php)
RewriteRule ^(.*)$ index.php?l=$1 [L]
和php:
<?php
$links = parse_ini_file('links.ini');
if(isset($_GET['l']) && array_key_exists($_GET['l'], $links)){
header('Location: ' . $links[$_GET['l']]);
}
else
include ('index.html');
?>
在 links.ini 我有短网址和网站网址:
youtube1 = "https://www.youtube.com/watch?v=9bZkp7q19f0"
youtube2 = "https://www.youtube.com/watch?v=wcLNteez3c4"
etc.
这些文件在根目录和 url 缩短工程中。
在 index.html 中,我有带有静态 html 页面的菜单:
<a href="/" >Home page</a>
<a href="page1" >page1</a>
<a href="page2" >page2</a>
etc.
但是当我点击它们时它只会重新加载 index.html?
如有任何帮助,将不胜感激!
我尝试将静态 html 链接放入 links.ini:
page1 = page1
但这也不起作用...我收到 页面未正确重定向错误。
【问题讨论】:
-
你试过
var_dump($links);吗?
标签: php html .htaccess url-shortener