2013-06-27 67 views
0

我想從一個域重定向到另一個 像重定向與的.htaccess

www.mydomain.com/abc/def/ghi.html 

對此

www.myanotherdomain.com/index.php?c=abc&s=def&p=ghi.html 

有誰能夠解決這個問題?

回答

0

此規則將只接受帶有3個參數的URL(不少於,不多於)。
每一個可以包含數字,字母和-(換句話說:[a-zA-Z0-9_-]

RewriteEngine On 
RewriteBase/
RewriteRule ^([\w-]+)/([\w-]+)/([\w-]+)\.html$ http://myanotherdomain.com/index.php?c=$1&s=$2&p=$3 [L,R=301] 

可以修改此htaccess的,以允許1,2或3個參數:

RewriteEngine On 
RewriteBase/
RewriteRule ^([\w-]+)\.html$ http://myanotherdomain.com/index.php?c=$1 [L,R=301] 
RewriteRule ^([\w-]+)/([\w-]+)\.html$ http://myanotherdomain.com/index.php?c=$1&s=$2 [L,R=301] 
RewriteRule ^([\w-]+)/([\w-]+)/([\w-]+)\.html$ http://myanotherdomain.com/index.php?c=$1&s=$2&p=$3 [L,R=301]