drg14799 2014-10-01 04:35
浏览 40
已采纳

使用.htaccess重定向子域

I have a subdomain set up on my hosting: indiantimes.indianradio.net.au, that is being pulled from a folder in my /public_html folder: /public_html/indiantimes.com.au.

I am trying to write an .htaccess rule that will redirect it to that folder still, but retain the original url the user typed in: indiantimes.indianradio.net.au.

I have only been able to get the redirect working, i.e. (indiantimes.indianradio.net.au redirects to indianradio.net.au/indiantimes.com.au/), but I can't seem to get the redirect working so the url seen by the user, stays at: indiantimes.indianradio.net.au. The majority of the image urls are broken intil I am able to get the redirect working properly.

The .htaccess rule I was playing around with was:

RewriteEngine on

RewriteCond %{HTTP_HOST} ^indiantimes\.indianradio\.net\.au$ [OR]
RewriteCond %{HTTP_HOST} ^www\.indiantimes\.indianradio\.net\.au$
RewriteRule ^/?$ "http\:\/\/indianradio\.net\.au\/public_html\/indiantimes\.com\.au" [R=301,L]

What am I doing wrong with the redirect? Any help would be much appreciated! Thanks in advance!

  • 写回答

2条回答 默认 最新

  • dsarttv037029 2014-10-01 05:06
    关注

    You have to replace your sub folder name to be the same as your sub domain
    (indiantimes.com.au -> indiantimes).

    RewriteEngine On
    
    RewriteCond %{HTTP_HOST} ^indiantimes\.indianradio\.net\.au$
    RewriteCond %{REQUEST_URI} !^/indiantimes/
    RewriteRule (.*) /indiantimes/$1
    

    source

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 这个复选框什么作用?
  • ¥15 单通道放大电路的工作原理
  • ¥30 YOLO检测微调结果p为1
  • ¥20 求快手直播间榜单匿名采集ID用户名简单能学会的
  • ¥15 DS18B20内部ADC模数转换器
  • ¥15 做个有关计算的小程序
  • ¥15 MPI读取tif文件无法正常给各进程分配路径
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下
  • ¥15 setInterval 页面闪烁,怎么解决
  • ¥15 如何让企业微信机器人实现消息汇总整合