【问题标题】:.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]