【问题标题】:Using breadcrumb url's使用面包屑网址
【发布时间】:2021-04-08 18:23:47
【问题描述】:

我开发了一个包含大量文件的网站。 我已经为他们建立了一个目录并放在那里。

我需要知道我是否可以创建自定义 url 路径,以便我的社区看到该 url, https://mywebsite.com 而不是 https://mywebsite.com/modules/webview/pages/index.php

我还希望用户输入https://mywebsite.com/forum,例如,将他们带到, https://mywebsite.com/modules/webview/addons/forum 然后仍然显示https://mywebsite.com/forum

谢谢。

我在我的网站上使用 Smarty。

如果有帮助,这里是我的配置文件的内容。

<?php
session_start();
$conn = new mysqli("localhost", "root", "", "dev");
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}
   define ('ROOT_PATH', realpath(dirname(__FILE__)));
   define ('INCLUDE_PATH', realpath(dirname(__FILE__) . '/includes' ));
   define('BASE_URL', 'http://localhost/');

function getMultipleRecords($sql, $types = null, $params = []) {
 global $conn;
 $stmt = $conn->prepare($sql);
 if (!empty($params) && !empty($params)) {
    $stmt->bind_param($types, ...$params);
  }
  $stmt->execute();
  $result = $stmt->get_result();
  $user = $result->fetch_all(MYSQLI_ASSOC);
  $stmt->close();
  return $user;
}
function getSingleRecord($sql, $types, $params) {
  global $conn;
  $stmt = $conn->prepare($sql);
  $stmt->bind_param($types, ...$params);
  $stmt->execute();
  $result = $stmt->get_result();
  $user = $result->fetch_assoc();
  $stmt->close();
  return $user;
}
function modifyRecord($sql, $types, $params) {
  global $conn;
  $stmt = $conn->prepare($sql);
  $stmt->bind_param($types, ...$params);
  $result = $stmt->execute();
  $stmt->close();
  return $result;
}
?>

【问题讨论】:

  • 什么 http 服务器正在运行您的 http 脚本?
  • 现在我正在使用最新版本的 php 和 mysql 在 xampp 上运行它
  • 我们怎么能知道你的项目的结构和使用的编程技术,而你根本没有提到呢?请添加更多详细信息,否则您的问题将被关闭和/或否决。
  • XAMPP 不是服务器,尽管我们可以猜到您现在正在运行 Apache 2.4。
  • 是的,我不擅长用文字解释事情。我在语音通信方面做得更好。我只想制作一个假路径,将用户带到真实文件,同时仍然显示假文件

标签: php breadcrumbs


【解决方案1】:

在 Apache HTTP Server 中,使用 URL 重写。

选项 1

在应用的根目录中创建一个.htaccess 文件,内容如下:

RewriteEngine On
Options FollowSymLinks
RewriteRule / /modules/webview/pages/index.php
RewriteRule /forum /modules/webview/addons/forum

选项 2

如果您有权访问 httpd.conf,请将这些行插入到与您的应用根目录匹配的 &lt;Directory&gt; &lt;/Directory&gt; 中。

【讨论】:

  • 您的选项之一给我一个服务器错误。服务器错误!服务器遇到内部错误,无法完成您的请求。服务器过载或 CGI 脚本中存在错误。并且使用第二个选项我可以做到,但当我将其上传到我的网络主机帐户时却不行。
  • 我已经编辑了答案,在路径上添加了/。如果不起作用,请尝试阅读this...
  • 谢谢。但我想通了。我现在知道如何显示错误的 uri 路径并输入错误的 uri 路径并仍然显示真实文件。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2020-01-10
  • 1970-01-01
  • 2014-02-24
  • 2020-08-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多