【问题标题】:.htaccess redirect with parameters.htaccess 带参数重定向
【发布时间】:2012-03-26 22:38:12
【问题描述】:

我网站上的一个页面,网址是“http://example.com/image/33434”。

要在社交网站上分享此内容,我想将其缩小。我已经有一个域,如果您输入“http://exp.co/image/33434”,它将重定向您,但我希望短网址为“http://exp.co/i/33434” .

这可以通过 .htaccess 文件完成吗?

谢谢,乔希。

【问题讨论】:

  • 这些都没有解决吗?

标签: php .htaccess url redirect


【解决方案1】:

如果 example.com 和 exp.co 是同一应用程序上的不同主机,则执行以下操作:-

RewriteCond %{HTTP_HOST}      ^exp\.co$ [NC]
RewriteRule ^i/([^/]+)/?$     http://example.com/image/$1 [NC,R=301,L]

如果它们是不同的应用程序,那么您只需要:-

RewriteRule ^i/([^/]+)/?$     http://example.com/image/$1 [NC,R=301,L]

【讨论】:

    【解决方案2】:

    我猜.. 或者带有符号链接。

    RewriteEngine On
    RewriteBase  /i/
    RewriteRule ^([^\.].*)$ /image/$0 [L]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-04-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-07-01
      • 2013-04-07
      相关资源
      最近更新 更多