【问题标题】:Try to make a redirection with .htaccess尝试使用 .htaccess 进行重定向
【发布时间】:2023-02-24 04:26:03
【问题描述】:

我想将诸如 http://198.54.7.120:8080/api/licence/azedf-ykht-tjyk-tykgt 之类的链接重定向到指向我服务器上 .htaccess 文件中诸如 http://198.54.7.120/projet/cryptage/frontend.php 之类的 php 文件的链接。我想这样做是为了确保我可以控制向数据库发送请求以检索许可证,并且它不是执行此操作的 API。

我试过下面的代码但没有定论

RedirectPermanent http://198.54.7.120:8080/api/licence/15205c3c-8fc5-4e70-916e-5d7a231079d3 http://198.54.7.120/project/cryptage/frontend.php

【问题讨论】:

  • 您配置的 RedirectPermanent 规则与您在问题中提出的内容不匹配。你想重定向所有内容 /apo/licence/* ?确保你1个加载重定向模块2个设置日志并将 LogLevel 更改为较高的值(如 trace8),以便您查看生成的错误消息。3个您的 Apache 必须同时监听 8080 和 804个并且两者都有 VirtualHost 配置。5个重写引擎开启。
  • RedirectPermanent 的文档明确指出,第一个参数是网址路径,不是网址:httpd.apache.org/docs/2.4/mod/mod_alias.html#redirectpermanent
  • 正如上面评论的那样,你不会用 .htaccess 实现你想要的,你应该在 apache2 服务器配置中设置它。

标签: apache .htaccess


【解决方案1】:

如果您可以控制您的服务器,您可以在 apache2 conf 文件 vhosts.conf 或类似文件中尝试:


<VirtualHost 198.54.7.120:8080>
#
# ...
#

RedirectPermanent /api/licence/15205c3c-8fc5-4e70-916e-5d7a231079d3 http://198.54.7.120/project/cryptage/frontend.php

#
# ...
#
</VirtualHost>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-03-31
    • 2015-10-24
    • 2018-09-05
    • 2011-08-29
    • 2017-04-15
    • 2013-06-24
    • 2015-08-15
    相关资源
    最近更新 更多