运行 来自 php 的 .htaccess + $_GET 友好 url + cURL 问题

Running .htaccess from php + $_GET friendly urls + cURL issue

我需要问你如何从 PHP 运行 .htaccess 因为我正在制作软件,但我希望用户可以通过语言设置他们自己的名字 links,但我只能在 .htaccess 中执行此操作,但在 .htaccess 中,我不知道如何从 PHP 语言中获取,然后使用它来指定将要使用哪些补丁现存的。我还想在 PHP 中创建友好的 URL(从 .php?id=0.php/id/0)。

最后一个...cURL。

我看到在一个软件中,我如何使用 cURL 读取页面文本(我有 link my.ip.com/idk.php?id=3 并且来自服务器的 id 3 只会说文本 "ok" 并且我想将该文本发送到 PHP 并使用它)

1) 你不能 运行 .htaccess 与任何东西。它是您的 Web 服务器的配置文件。

2) http://you.com/@username

示例
RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^@(.+)$ profile.php?username= [L,QSA]

然后在profile.php

中得到$_GET["username"]

3) 你应该制作自己的 .htaccess RewriteRule

4) 关于 cURL 的小例子。

<?php
$post = [
    'PostName' => 'PostValue'
];
$ch = curl_init('http://www.example.com');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
$response = curl_exec($ch);
curl_close($ch);
var_dump($response);
?>