2
RewriteEngine On
RewriteRule ^/ai?$ /Market/publish.jsp [QSA,L,PT]
RewriteRule ^/ar?$ /Market/MailDispatch [QSA,L,PT]
RewriteCond %{HTTP_HOST}   !^web\.example\.com [NC]
RewriteCond %{HTTP_HOST}   !^$
RewriteRule ^/(.*)         http://web.example.com/$1 [L,R]
#How skip www\. to web\. for this 1 ? 
#RewriteRule ^/vi/?([0-9]+)\.htm$ /Market/vi.do?id=$1 [PT,L]                    
RewriteRule ^/li /Market/list.do [QSA,PT,L]
RewriteRule ^/vi/locations.jsp /Market/locations.jsp [PT,L]
ErrorDocument 404 /notfound.html

Nearly undoable(?) I try http://example.com/vi/{N}.htm should redirect to http://web.example.com/vi/{N}.htm where N is dynamic ID.

Seen mod_rewrite with subdomain and url pattern There is no clear way to make eg http://example.com/vi/1096.htm pass up to next version http://web.example.com/vi/1096.htm where number is dynamic. I tried

Community
  • 1
  • 1
Niklas Rosencrantz
  • 25,640
  • 75
  • 229
  • 424
  • What do you mean by "pass up to next version"? Based on your example, your existing code should do what you want (although maybe your `RewriteRule` statements shouldn't have leading `/`), so I think I'm misinterpreting your question; could you try and clarify what you mean? – Tim Stone Jul 13 '10 at 13:58
  • Glad it works now meaning migrating template by template from LAMP to GAE – Niklas Rosencrantz Jul 23 '10 at 19:56

1 Answers1

1

A rule with the following scheme should do it:

RewriteCond %{HTTP_HOST} ^example\.com$
RewriteRule ^/vi/\d+\.htm$ http://web.example.com%{REQUEST_URI} [L,R=301]

It’s important to put this rule in front of those rules that do an internal redirect. Otherwise an already internally rewritten URL could be rewritten externally.

If you want to use this rule in a .htaccess file, remove the leading slash from the pattern in RewriteRule.

Gumbo
  • 643,351
  • 109
  • 780
  • 844