gpt4 book ai didi

url - 在文件名旁边使用斜杠符号?

转载 作者:行者123 更新时间:2023-12-04 20:08:03 29 4
gpt4 key购买 nike

是否可以让我的网站在文件名后接受斜杠并将斜杠作为 url 的结尾

举个例子:

http://example.com/files/file.php

这将正常加载

我也希望它通过这个加载: http://example.com/files/file.php/whateverhere

只是忽略 .php 之后的所有内容,所以它不会给出未找到的错误

最佳答案

在您的 DocumentRoot 中添加一个包含以下内容的 .htaccess:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^(.*).php/(.*)$ $1.php [L]
</IfModule>

这会丢弃 .php 之后的所有内容。如果您想将其作为 GET 查询字符串的一部分传递,请将规则更改为:

RewriteRule     ^(.*).php/(.*)$     $1.php?foo=$2  [L]

关于url - 在文件名旁边使用斜杠符号?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7655180/

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