强制网页存在于'/'?

Force webpage to exist at '/'?

是否有可能 URL 像:

http://example.com//

我知道末尾的 'forward slash' 无效(因为无法命名页面:'/' 或者可以吗?) - 但是有没有办法,通过使用 .htaccess 来强制网页存在于该位置(索引页除外)。

因此,http://example.com/ 是索引页面,但是当用户键入:http://example.com// 他们会得到另一个网页。

你看,我的问题是我需要一个 'one character' 页面 - 为了保持一致性,'/' 是最好的。

(我知道不推荐这样做:可能会引发负面反应 - 但出于兴趣,我正在看看这是否可行 - .htaccess 解决方案会很棒。)

您可以通过以下方式执行此操作:

DirectoryIndex index.php
RewriteEngine On

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s//[\s?]
RewriteRule ^ another-page.php [L]

这将为 http://example.com/ 显示 /index.php,为 http://example.com// 显示 /another-page.php