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 利用pthon计算薄膜结构的光导纳
  • ¥15 海康hlss视频流怎么播放
  • ¥15 Paddleocr:out of memory error on GPU
  • ¥30 51单片机C语言数码管驱动单片机为AT89C52
  • ¥100 只改动本课件的 cal_portfolio_weight_series(decision_date), 跑完本课件。设计一个信息比率尽量高的策略。
  • ¥20 如何在visual studio 2022中添加ImageMagick库
  • ¥50 如何实现uniapp编译的微信小程序做可回溯视频
  • ¥15 求Houdini使用行家,付费。价格面议。
  • ¥15 前端高拍仪调用问题报错
  • ¥15 想用octave解决这个数学问题