apache - mod_rewrite all but root -


i trying craft mod_rewrite conditions , rules requests domain other "/" re-mapped new domain are, while requests "/" mapped particular path on new domain.

for instance;
siteone.domain.com/some/great/path goes to
sitetwo.domain.com/some/great/path

while;
siteone.domain.com/ goes to
sitetwo.domain.com/some/other/path

the first part easy, , although i've read several howto's on excluding particular directories or files mod_rewrite rule, cannot second work. attempts have ended with;
siteone.domain.com/ goes to
sitetwo.domain.com/

following @ now. attempting deal requests root first, else;

rewritecond %{request_uri} ^/$ rewriterule http://sitetwo.domain.com/some/other/path [r=301]  rewritecond %{http_host} ^siteone\.domain\.com$ rewriterule (.*) http://sitetwo.domain.com/$1 [r=301,l] 

i'm sure i'm missing basic, going around in circles now.

the logs if both rules being processed. had assumed stop @ first match.

... (2) init rewrite engine requested uri / ... (3) applying pattern 'http://sitetwo.domain.com/some/other/path' uri '/' ... (3) applying pattern '(.*)' uri '/' ... (2) rewrite '/' -> 'http://sitetwo.domain.com/' ... (2) explicitly forcing redirect http://sitetwo.domain.com/ ... (1) escaping http://sitetwo.domain.com/ redirect ... (1) redirect http://sitetwo.domain.com/ [redirect/301] 

i guess i'm needing sort of if/else statement? if first condition maths rewrite, else move second condition , rule. i'm missing?

i seem have stumbled across problem, , suspected silly missing. adding (.*) first rewriterule seems have resolved issue.

so, instead of

rewritecond %{request_uri} ^/$ rewriterule http://sitetwo.domain.com/some/other/path [r=301,l] 

i needed

rewritecond %{request_uri} ^/$ rewriterule (.*) http://sitetwo.domain.com/some/other/path [r=301,l] 

Comments

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -