如何在htaccess中创建类似YouTube的短域重定向


How can I create a YouTube-like short domain redirection in htaccess?

首先,我想说什么是类似YouTube的短域重定向:

如果您转到:youtu.be/jwslDn3ImM0

它将重定向至:www.youtube.com/watch?v=jwslDn3ImM0

就我而言。我有两个域名:somethinghere.besomethingheretube.com,我想做同样的事情YouTube。

如何在 .htaccess 中使用最高效、最快速、最安全的方式实现此目的?并不是说我在主域 somethinghere.be 上的.htaccess仍然是空的。

我知道我将不得不使用:

RewriteCond
RewriteRule

但我不知道如何进行。

您可以在

tedtu.be文件夹中的.htaccess中使用:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/?$ http://tedtube.com/watch?v=$1 [L,R=301]