【发布时间】:2021-06-29 07:13:18
【问题描述】:
我有一个网站http://sharenotes.xyz/。
在这个网站上,用户可以保存和分享快速笔记给其他用户。
每个笔记都有一个唯一的笔记 ID。 (id 只能包含 [0-9A-Za-z_] 字符)。
网址中存在唯一的笔记 ID http://sharenotes.xyz/hithere。
在这种情况下,hithere 是唯一的便笺 ID。
实际上,网址就像
http://sharenotes.xyz/index.php?id=hithere.
我的文件夹结构看起来像 -
并且 index.php 文件存在于公用文件夹中。.htaccess 文件的内容是什么,以将 url 从 http://sharenotes.xyz/index.php?id=hithere 缩短到 http://sharenotes.xyz/hithere 以及我应该将该 .htaccess 文件放在哪个文件夹中?
我知道 php,但我是 htaccess 文件中的新手(存储在 public_html 文件夹中)。
更新
我忘了告诉你一件事-
有一个名为 public 的文件夹,它为所有用户可访问的文件提供服务。
所以我还通过 .htaccess 文件从 url 中隐藏了 public 的名称。
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ public/ [L]
RewriteRule (.*) public/$1 [L]
</IfModule>
Options -Indexes
这就是为什么你不会在 url 中看到 public。
【问题讨论】: