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!

图片转代码服务由CSDN问答提供 功能建议

我在托管上设置了子域名: indiantimes.indianradio.net.au ,这是从 / public_html 文件夹中的文件夹中提取的: /public_html/indiantimes.com.au

我是 尝试写一个.htaccess规则,将其重定向到该文件夹​​,但保留用户输入的原始URL: indiantimes.indianradio.net.au < p>我只能使重定向工作,即( indiantimes.indianradio.net.au 重定向到 indianradio.net.au/indiantimes.com.au / ),但我似乎无法使重定向工作,因此用户看到的URL保留在: indiantimes.indianradio.net.au 。 大多数图片网址都被破坏了,我可以让重定向正常工作。

我正在玩的.htaccess规则是:

  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] 
   
 
 

我在重定向方面做错了什么? 任何帮助将非常感激! 提前致谢!

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 收藏
  • 邀请回答

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条)

相关推荐 更多相似问题