gpt4 book ai didi

php - 如何在 .htaccess 中创建别名以更改本地 URL

转载 作者:行者123 更新时间:2023-12-05 05:25:54 25 4
gpt4 key购买 nike

我很确定这是重复的,但我只是不知道如何找到这个简单问题的答案。

所以我有一个像这样的本地页面:

http://example.com/mypage.php

我想做的就是让任何试图访问 http://example.com/subfolder/mypage.php 的人在上述位置实际加载页面。

我不想重定向。 http://example.com/subfolder/mypage.php 在我的服务器上不作为实际路径存在,但我想通过 .htaccess 中的规则使其可用

最佳答案

试试这个:

RewriteEngine on
RewriteRule ^subfolder/(.*) /$1

此规则将每个以 /subfolder/ 开头的请求重写为 /。或者,如果您只需要特定的 URL 路径:

RewriteEngine on
RewriteRule ^subfolder/mypage.php /mypage.php

关于php - 如何在 .htaccess 中创建别名以更改本地 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29161543/

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