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 求解 yolo算法问题
  • ¥15 虚拟机打包apk出现错误
  • ¥30 最小化遗憾贪心算法上界
  • ¥15 用visual studi code完成html页面
  • ¥15 聚类分析或者python进行数据分析
  • ¥15 三菱伺服电机按启动按钮有使能但不动作
  • ¥15 js,页面2返回页面1时定位进入的设备
  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝