apache - 短网址和预览数据

我正在使用以下规则来生成短网址,

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

现在的问题是,当我在推特上分享短网址时,它不会给你私有(private)图像或数据,

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

最佳答案

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

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

然后您的缩短代码应该正常进行查找,但在重定向中包含 maindomain.com,例如在 PHP 中,这将如下所示:

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

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

https://stackoverflow.com/questions/40611945/

相关文章:

apache - 别名和重写器一起工作

php - Google 短网址 - 最大网址长度

short-url - 新浪微博的短网址?

short-url - 谷歌 URL 缩短 API : Converting a long URL

javascript - 在社交媒体上分享我网站上的网页时如何缩短网址?

google-app-engine - 使用 Google Analytics 进行 Google

short-url - goo.gl 短网址的集体统计数据

asp.net - 用户名和 umbracoUrlAlias 发生冲突

javascript - 尽管有同源策略,但不缩短短 URI

javascript - 通过 JavaScript 解析 t.co url