【问题标题】:short url and preview data短网址和预览数据
【发布时间】:2017-03-29 11:02:07
【问题描述】:

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

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

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

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

【问题讨论】:

    标签: apache mod-rewrite short-url


    【解决方案1】:

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

    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);
    

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

    【讨论】:

    • @Jecki 您可能还需要将DPI 标志添加到规则中。
    猜你喜欢
    • 1970-01-01
    • 2018-05-28
    • 1970-01-01
    • 1970-01-01
    • 2016-12-15
    • 2010-11-25
    • 1970-01-01
    • 1970-01-01
    • 2013-02-04
    相关资源
    最近更新 更多