开发者

::: Mod Re-Write /SubDir/ Content --> SubDomain Content

开发者 https://www.devze.com 2023-01-24 08:23 出处:网络
is this possi开发者_开发技巧ble with Mod Re-Write? IF either mobile users OR searchbots enter server1.com/mobile/

is this possi开发者_开发技巧ble with Mod Re-Write?

  1. IF either mobile users OR searchbots enter server1.com/mobile/
  2. server1/mobile/ url DOES NOT change and
  3. the content is served from foo.server1.com


Yes, this can be done using mod_rewrite:

RewriteEngine On    
RewriteCond %{REQUEST_URI} ^/mobile
RewriteCond %{HTTP_USER_AGENT}  ^(iPhone.*|GoogleBot.*)
RewriteRule (.*) http://foo.server1.com%{REQUEST_URI}

Note that with this approach you'd have to list every user-agent you want to match. You could have it all in one rule as I've done, or you could have a separate line for each one.

0

精彩评论

暂无评论...
验证码 换一张
取 消