gpt4 book ai didi

php - 将非扩展文件定向到 .php

转载 作者:可可西里 更新时间:2023-11-01 00:27:55 25 4
gpt4 key购买 nike

我有一个扩展名为 .php 的文件 www.example.com/thefile.php?name=123 如果用户访问以下任何别名,我想将其引导至该文件:

www.example.com/alias?name=123
www.example.com/unreal?name=123
www.example.com/fake?name=123

有没有一种方法可以在不使用已经使用此结构的框架的情况下完成此操作?我正在使用纯 PHP。

最佳答案

是的,你可以,如果你的 Apache 服务器上激活了 mod_rewrite,你可以在你网站的根目录下添加一个 .htaccess 文件,并在其中添加类似的东西(不是 100% 确定,因为我家里没有 Apache):

RewriteRule ^(alias|unreal|fake)$ thefile.php [QSA]

可以咨询Apache mod_rewrite doc here

关于php - 将非扩展文件定向到 .php,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1654992/

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