php - 检测链接何时被单击,在新框架中打开

标签 php javascript jquery

我想使用框架创建基本的 URL 重写。

我无权访问 .htaccess 来执行 mod_rewrite

有没有办法使用 PHP、jQuery、JavaScript 等来检测哪个 URL 被点击,然后在新框架中打开 URL?

例如:用户点击 /index.php?12345 它将在框架窗口 /pages/12345/index.html 中打开,并且如果他们点击 /index.php?54321 URL 将在框架窗口中打开 /pages/54321/index.html

最佳答案

我想我不太明白你的意思。通常 url 重写的工作方式如下:
用户点击http://example.com/content/example
重写为http://example.com/index.php?cat=content&page=example

您可以通过将链接设置为 http://example.com/index.php/content/example 来伪造这种效果。网络服务器仍然会请求页面index.php,然后您可以在其中读取index.php之后(但在查询字符串之前)的部分

$_SERVER['PATH_INFO']

然后解析它以获得您需要的内容。

$_SERVER['PATH_INFO'] 上的 PHP.net

Contains any client-provided pathname information trailing the actual script filename but preceding the query string, if available. For instance, if the current script was accessed via the URL http://www.example.com/php/path_info.php/some/stuff?foo=bar, then $_SERVER['PATH_INFO'] would contain /some/stuff.

关于php - 检测链接何时被单击,在新框架中打开,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1516662/

相关文章:

php - 使用 1(插入)按钮,我可以将 HTML 表中的多行数据插入到 MySQL 数据库表中吗?

php - Symfony2 - 安装了 FOS 用户包的自定义身份验证提供程序

javascript - 打印工作日并检查该工作日是否存在日期

宽度为 50% 的 JQuery 数据表

php - SSL 工具不适用于 MySQL Workbench

php - cakephp - 搜索整个模型和 HasManys 并使用通配符

javascript - 在 ExtJS 5.1 中触发自定义事件

javascript - 更改传单图层控件图标

javascript - 如何在 Javascript/jQuery 中动态切片数组?

jquery - 具有自定义背景图像的可变高度 div - 最好的技术是什么?