如何从链接隐藏文件夹名称

发布于 2025-01-21 23:51:29 字数 80 浏览 1 评论 0 原文

域/页/asd.php

我有一个我想隐藏页面文件夹的链接。人们需要在链接上写入域/asdf.php并在文件夹中访问文件,我该怎么做?

domain/pages/asd.php

I have a link in the form of I want to hide the pages folder. People need to write domain/asdf.php on the link and reach the file in the folder, how can I do it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

病毒体 2025-01-28 23:51:29

将以下内容添加到您的 .htaccess 文件中,

RewriteEngine on
RewriteRule ^pages/(.+)$ /$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.+) /pages/$1 [END]

这将确保用户只能通过新路由(/asd.php )访问URL,而不是通过两者(即/asd.php & /pages/asd.php )。

View rewrite output

Add the following to your .htaccess file

RewriteEngine on
RewriteRule ^pages/(.+)$ /$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.+) /pages/$1 [END]

This will ensure users can only access the url by the new route only (/asd.php) and not via both (I.e /asd.php & /pages/asd.php).

View rewrite output

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文