apache - How can I make my two htaccess files the same in a test and live system? -
for website, have test directory , live directory. inside both have .htaccess file differs , i'd make them same if possible. difference between 2 test system not use https while live system , have 2 different urls.
.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]
.htaccess live
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]
edit tried solution @hello fishy got
server error! server encountered internal error , unable complete request. either server overloaded or there error in cgi script. if think server error, please contact webmaster. error 500
server.config (test site)
target_server http://www.test_example.org https_switch off
.htaccess modified (test site)
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]
rewritemap
answer. i'd place servers.txt
(or whatever you'd call it) in same folder .htaccess (it can in folder though). should include on test-system:
target_server http://www.test_example.org https_switch off
and ofc this, accordingly, on live-system
target_server http://www.live_example.com https_switch on
your rewrites have include servers.txt this:
rewritemap servers txt:conf/servers.txt
with /conf
potential .htaccess-folder , servers
alias you'll reference in rewrites-conf. rewrites same on both systems:
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]
Comments
Post a Comment