短 url 和预览数据

short url and preview data

我使用以下规则生成短 url ,

RewriteCond %{HTTP_HOST} ^(www\.)?domain2\.com$ [NC]
RewriteRule  ^  http://maindomain.com/shortener%{REQUEST_URI} [L,NE]

example  of the short url domain2.com/j3

它将被重定向到

http://maindomain.com/shortener/j3

然后它会击中实际 url

http://maindomain.com/web/article/section/192392

现在的问题是,当我在推特上分享短片 url 时,它并没有给你隐私图像或数据,

此处有任何建议调整重写规则或其逻辑本身需要调整

尝试将其减少到一个重定向:

RewriteCond %{HTTP_HOST} ^(?:www\.)?shortdomain\.com$ [NC]
RewriteRule ^(?!shortener/).+ shortener/[=10=] [NS,L]

那么您的缩短代码应该像往常一样进行查找,但在重定向中包含 maindomain.com,例如在 PHP 中将如下所示:

header("Location: http://maindomain.com/$expanded_path", true, 301);

这假设您的短域只是主域的别名,因此它们具有相同的代码库。