2017-04-06 9 views
0

私のウェブサイトには、テストディレクトリとライブディレクトリがあります。両方の内部では、.htaccessファイルが少し異なります。可能であれば、それらを同じにしたいと思います。 2つの違いは、テストシステムではhttpsを使用していないが、ライブシステムでは2つの異なるURLがあるという点です。テストシステムとライブシステムの2つのhtaccessファイルを同じにするにはどうすればよいですか?

の.htaccess TEST

RewriteRule ^(.*)index.html$ http://www.TEST_example.org/$1 [R=301,L] 
RewriteCond %{HTTP_HOST} ^TEST_example\.org [NC] 
RewriteRule ^(.*) http://www.TEST_example.org/$1 [R=301,L] 

#further down... 
#RewriteCond %{HTTPS} off 
#RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] 

RewriteRule ^(.*)index.html$ http://www.LIVE_example.com/$1 [R=301,L] 
RewriteCond %{HTTP_HOST} ^TEST_example\.org [NC] 
RewriteRule ^(.*) http://www.LIVE_example.com/$1 [R=301,L] 

#further down... 

RewriteCond %{HTTPS} off 
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] 
01 LIVEの.htaccess

EDIT は私が@Helloうさんくさいから解決策を試してみましたが、私は

Server error! 

The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there was an error in a CGI script. 

If you think this is a server error, please contact the webmaster. 

Error 500 

server.config(TESTサイト)

target_server http://www.TEST_example.org 
https_switch off 

.htaccessの変更(TESTサイト)

を得ました
RewriteMap servers txt:server.config 

RewriteRule ^(.*)index.html${servers:target_server}/$1 [R=301,L] 

RewriteCond %{HTTP_HOST} ^TEST_example\.org [NC] 
RewriteRule ^(.*) ${servers:target_server}/$1 [R=301,L] 

#further down... 
RewriteCond %{HTTPS} ${servers:https_switch} 
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] 

答えて

0

あなたの答えはです。私はservers.txt(またはあなたがそれを呼びたいと思っているもの)をあなたの.htaccessと同じフォルダに置きます(それは別のフォルダにもあります)。

target_server http://www.LIVE_example.com 
https_switch on 

あなたの書き換えは、このようなて、Servers.txtを含める必要があなたのLIVE-システム上で、それに応じて

target_server http://www.TEST_example.org 
https_switch off 

と、このOFC、:それはあなたのTEST-システム上でこれを含める必要があります

RewriteMap servers txt:conf/servers.txt 

潜在的な.htaccess-folderとして/conf、そしてserversを別名として、rewrites-confで参照してください。 その後書き換えは、両方のシステムで同じである。

RewriteEngine On 
RewriteMap servers txt:conf/servers.txt 

RewriteRule ^(.*)index.html$ ${servers:target_server}/$1 [R=301,L] 

RewriteCond %{HTTP_HOST} ^TEST_example\.org [NC] 
RewriteRule ^(.*) ${servers:target_server}/$1 [R=301,L] 

#further down... 
#RewriteCond %{HTTPS} ${servers:https_switch} 
#RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] 
+0

何ライン#RewriteCond%、約{HTTPS}オフ/各サーバ上の異なるされています? – AllisonC

+0

あなたは本当にそこにいます!私は違いを探していましたが、見つけたと思って、新しいバージョンを書きました。両方が同じhttps設定を持っていることを認識するだけです^ –

+0

私は '$ {servers:https_switch}' TESTでhttpsをオフにし、LIVEで 'on 'にしたかったと仮定しました。そうでない場合は、それに応じてservers.txtを編集してください;) –

関連する問題