-2

I have developed a website that has a lot of files. I have made a directory for them and put it there.

i need to know if i can make a Custom url path so that my community to see the url, https://mywebsite.com instead of https://mywebsite.com/modules/webview/pages/index.php.

And i also want that is users type in https://mywebsite.com/forum for example so takes them to, https://mywebsite.com/modules/webview/addons/forum and then still display https://mywebsite.com/forum

Thank you.

I am using Smarty on my website.

Here is the contents of my config file if it helps.

<?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;
}
?>
  • What http server is running your http scripts? – Nathan Xabedi Apr 08 '21 at 18:27
  • Well right now i am running it on xampp with the latest version of php and mysql – Phelix Fox Apr 08 '21 at 18:28
  • How can we know the structure and used programming techniques of your project while you didn't mention that at all? Please add some more details or your question will bo closed and/or downvoted. – biesior Apr 08 '21 at 18:29
  • XAMPP is not a server, although we can guess you're running Apache 2.4 now. – biesior Apr 08 '21 at 18:29
  • Yea i am not good at explaining things in text. i do it better over voice communications. I just want to make a fake path that takes users to the real file while still displaying the fake one – Phelix Fox Apr 08 '21 at 18:32
  • Also what you're describing is not a breadcrumb rather some kind of URL rewriting, please specify better what you want to achieve. It's better to invest several minutes to write a good question instead of using wrong terminology. – biesior Apr 08 '21 at 18:35
  • I want to build a customized path, like templates. To view the page from the real path while displaying a non existing path. make sence? Also i edited the question. – Phelix Fox Apr 08 '21 at 18:41

1 Answers1

0

In Apache HTTP Server, use URL rewriting.

Option 1

Create a .htaccess file in the root directory of your app, with this content:

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

Option 2

If you have access to the httpd.conf, insert those lines in the <Directory> </Directory> matching the root of your app.

Nathan Xabedi
  • 1,097
  • 1
  • 11
  • 18
  • Your option one gives me a server error. Server error! The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there was an error in a CGI script. and with the second option i can do it but not when i upload it to my web host account. – Phelix Fox Apr 09 '21 at 09:28
  • I have edited the answer, added `/` on the paths. If it does not work, try to read [this](https://httpd.apache.org/docs/current/mod/mod_rewrite.html)... – Nathan Xabedi Apr 09 '21 at 15:29