1

假设 short.com 是短域,long.com 是长域

更新:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^www.long.com
RewriteRule (.*) http://long.com/ [R=301]

RewriteCond %{HTTP_HOST} ^short\.li$ [NC]
RewriteCond %{REQUEST_URI} !^/redirect
RewriteRule ^(.*)$ /redirect?short=$1 [L,R=301]

RewriteCond %{HTTP_HOST} ^(www\.)short\.li$
RewriteRule ^$ http://long.com/ [L,R=301]

两个域都指向该根目录。当我输入 short.li 时,我最终会访问 long.com/?l= 我是怎么搞砸的?^^

4

2 回答 2

2

在你的 htaccess 文件中试试这个:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)short\.com$
RewriteRule ^$ http://www.long.com/ [L,QSA,R=301]

RewriteEngine on如果它已经存在则删除

于 2012-08-16T15:12:52.080 回答
0

我想你可能想要这样的东西:

RewriteEngine on
RewriteCond {REQUEST_URI} !/
RewriteCond {HTTP_HOST} short.com
RewriteRule ^(.*) http://long.com/redirect.php?short=$1 [L,R=301]

RewriteCond {REQUEST_URI} /
RewriteCond {HTTP_HOST} short.com
RewriteRule ^(.*) http://long.com/ [L,R=301]

不确定最后一个是否需要正则表达式,但是这样的东西应该可以

于 2012-08-16T15:18:20.723 回答