gpt4 book ai didi

apache - 如何使用 Apache 制作自定义 URL 解析器?

转载 作者:行者123 更新时间:2023-12-01 23:51:36 27 4
gpt4 key购买 nike

我听说这可以通过 web.config 文件来完成。我想这样做,例如,我的 URL http://help.BHStudios.org/site 可能转到 http://BHStudios.org/help.php?section= sitehttp://i.BHStudios.org/u3Hiu 可能会重定向到存储在数据库中的其他一些 URL,其中散列 u3Hiu 作为键,或者如果出现问题并且内部文件结构被公开,如 http://Kyli.BHStudios.org/http/bhstudios/v2/self/index.php原因)它会在向用户公开之前将其更改为预期的 URL http://Kyli.BHStudios.org

由于我以前从未这样做过,能否请您也解释一下您给出的答案的原因?

最佳答案

几个Apache mod_rewrite rules在您的服务器 httpd.conf 或 .htaccess 文件中,在您的 htdocs 目录中将执行您想要的大部分操作,例如

RewriteEngine On
RewriteBase /

# Default Rule - for non physical objects (not a file or directory):
# Internally rewrite (user won't see the URL) to /index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ /index.php [L]

#If the Browser request contains a .php, instruct the browser to remove it.
RewriteCond %{THE_REQUEST} \.php [NC]
RewriteRule ^/?(.*)\.php$ http://%{HTTP_HOST}/$1 [R=301,NC,L]

# Specific rule
RewriteRule ^/?site /help.php?section=site

真实文件系统对象的屏蔽不会是完美的,而且有点毫无意义,因为用户只需要在任何服务页面上右键单击并查看源代码,以获得实际的 URL。

关于apache - 如何使用 Apache 制作自定义 URL 解析器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26222856/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com