URL 没有参数但 PHP 获取参数(.htaccess?)

URL without parameters but PHP gets Parameter (.htaccess?)

(抱歉我的英语不好。我来自德国)

我正在努力为 Imageviewer 争取 URLs。

我刚得到子域的 htaccess 代码

RewriteEngine on
RewriteCond %{HTTP_HOST} i.domain.de$
RewriteCond %{REQUEST_URI} !^/imageviewer
RewriteRule ^(.*)$ /imageviewer/ [L] 

这就是我希望看到的结果。如果我导航到 i.domain.de,浏览器会显示正确的 URL 并显示来自 /imageviewer/ 的 index.php。

但我想要漂亮的 URLs。现在我有 URLs,参数如 i.domain.de/?id=2ntxfii.domain.de/index。 php?id=2ntxfi 但我希望它是 i.domain.de/2ntxfi/ PHP 仍应获得 $_GET['id'] 参数。

我怎样才能做到这一点?

旁注:我有一个虚拟服务器。因此,如果需要,我可以安装 Apache 扩展。

创建一个名为 /imageviewer/.htaccess 的文件并使用以下代码:

RewriteEngine On
RewriteBase /imageviewer/

# If the request is not for a valid directory
RewriteCond %{REQUEST_FILENAME} !-d
# If the request is not for a valid file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.+) index.php?id= [L,QSA]