douzuan5365 2012-04-15 16:43
浏览 30
已采纳

使用URL REWRITE将辅助域重定向到主机帐户上的文件夹

I have two domains and one hosting account. I want the new domain to point to a sub-folder in my hosting account.

I've made a "HOST A" redirection for the new domain, so now when i type SECONDARY.COM (for example) i reach the root of the hosting (the same as if i was typing PRIMART.COM).

I then added a .htaccess file with this content :

Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^secondary\.co\.il$ [NC]
RewriteRule ^(.*)$ http://www.primary.il/secondary$1 [R=301,L]

But seems like it changes nothing - When i type SECONDARY.COM i still reach the root and not the folder ("secondary").

Maybe something about the syntax, can't find the problem.

I've been trying almost anything but with no success, ANY help would be greatly appreciated.

Thanks in advance.

  • 写回答

1条回答 默认 最新

  • doulian8742 2012-04-15 18:00
    关注

    How about this? Looks a lot like what you're looking for :). Footnote: for underneath example primary.com offcourse also has to be a subfolder, which in my opinion is "cleaner".

    RewriteEngine On
    RewriteBase /
    
    RewriteCond %{HTTP_HOST}  secondary.com$ [NC]
    RewriteCond %{REQUEST_URI} !^/secondary.com/.*$
    RewriteRule ^(.*)$  /secondary.com/$1 [L]
    
    RewriteCond %{HTTP_HOST}  primary.com$ [NC]
    RewriteCond %{REQUEST_URI} !^/primary.com/.*$
    RewriteRule ^(.*)$  /primary.com/$1 [L] 
    

    Source: http://www.techrepublic.com/article/rewriting-urls-to-host-multiple-domains-on-a-single-ip-address-with-apache/6042903

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题