2017-11-25 19 views
0

私のサーバーには複数のページがあります。トラフィックがあり、他のウェブサイトにリダイレクトする必要があります。それは簡単な部分です。問題は、物事を混ぜ合わせて、人を新しいサイトにランダムに送る必要があるということです。.htaccessランダムURLにリダイレクト

私はtime_secでこれを行うことができますが、私の現在の知識は、私が試しても問題なく動作することが分かりました。

これは今で働いているコードである:

するRewriteCondの%{TIME_SEC} ^(0 | 4 | 8 | 12 | 16 | 22 | 26 | 30 | 34 | 38 | 42 | 46 | 50 | 54 | 58)
に、RedirectMatch 301 /my-page-1.php https://newsite.com/page1/discount

するRewriteCondの%{TIME_SEC} ^(1 | 5 | 9 | 13 | 17 | 23 | 27 | 31 | 35 | 39 | 43 | 47 | 51 | 55 | 59)
に、RedirectMatch 301 /my-page-1.php https://newsite.com/page1/offer

するRewriteCondの%{TIME_SEC} ^(2 | 6 | 10 | 14 | 18 | 24 | 28 | 32 | 36 | 40 | 44 | 48 | 52 | 56 | 60)
に、RedirectMatch 301 /my-page-1.php https://newsite.com/page1/email

するRewriteCond%{TIME_SEC}^(3 | 7 | 11 | 15 | 19 | 25 | 29 | 33 | 37 | 41 | 45 | 49 | 53 | 57)
に、RedirectMatch 301 /my-page-1.php https://newsite.com/page1/promo

.. 。 //ページの別...

するRewriteCondの%{TIME_SEC} ^(0 | 4 | 8 | 12 | 16 | 22 | 26 | 30 | 34 | 38 | 42 | 46 | 50 | 54 | 58)
に、RedirectMatch 301 /my-page-2.php https://newsite.com/page2/discount

するRewriteCondの%{TIME_SEC} ^(1 | 5 | 9 | 13 | 17 | 23 | 27 | 31 | 35 | 39 | 43 | 47 | 51 | 55 | 59)
に、RedirectMatch 301 /my-page-2.php https://newsite.com/page2/offer

するRewriteCondの%{TIME_SEC} ^(2 | 6 | 10 | 14 | 18 | 24 | 28 | 32 | 36 | 40 | 44 | 48 | 52 | 56 | 60)
に、RedirectMatch 301 /my-page-2.php https://newsite.com/page2/email

するRewriteCondの%{TIME_SEC} ^(3 | 7 | 11 | 15 | 19 | 25 | 29 | 33 | 37 | 41 | 45 | 49 | 53 | 57)
Redirec tMatch 301 /my-page-2.php https://newsite.com/page2/promo

は、だから、私は、トラフィックを得た私のサーバー上に複数の「私のページ-x.php」を持っていると私は、特定の新しいサイトにRANDOMLY行くためにトラフィックを必要としています。

このコードは、誤って動作しません。私は何百万という変更を試みたが、何もしなかった。

誰でも助けてくれますか?

答えて

0

ランダム性を達成するための素晴らしいアイデア。フル秒-文字列が値(だけではなく始まり)

2に対してチェックされるように

私は2つの調整

1を作ったが))TIME_SEC条件の行末に「$」を追加しました

RewriteEngine on 
RewriteBase/

RewriteCond %{REQUEST_FILENAME} ^my-page-1\.php$ 
RewriteCond %{TIME_SEC} ^(0|4|8|12|16|22|26|30|34|38|42|46|50|54|58)$ 
RewriteRule ^.*$ https://yoururl1.com [L, R=301] 

RewriteCond %{REQUEST_FILENAME} ^my-page-1\.php$ 
RewriteCond %{TIME_SEC} ^(1|5|9|13|17|23|27|31|35|39|43|47|51|55|59)$ 
RewriteRule ^.*$ https://yoururl2.com [L, R=301] 

RewriteCond %{REQUEST_FILENAME} ^my-page-1\.php$ 
RewriteCond %{TIME_SEC} ^(2|6|10|14|18|24|28|32|36|40|44|48|52|56|60)$ 
RewriteRule ^.*$ https://yoururl3.com [L, R=301] 

RewriteCond %{REQUEST_FILENAME} ^my-page-1\.php$ 
RewriteCond %{TIME_SEC} ^(3|7|11|15|19|25|29|33|37|41|45|49|53|57)$ 
RewriteRule ^.*$ https://yoururl4.com [L, R=301] 
:これはあなたのアプローチを修正する必要があり RewriteRule

必要な書き換え相手とRedirectMatchを切り替えます

関連する問題