【问题标题】:Redirect subdomain whatever the request is to another domain using htaccess使用 htaccess 将子域重定向到另一个域
【发布时间】:2016-12-17 18:40:40
【问题描述】:

我有一个网站,其中有一个按钮可以创建随机图片并将其添加到 ../wf/pix/random-name.png

因此,例如,您将继续 create.my-domain.com 并单击一个按钮以在 create.domain.com/create/wf/pix 生成随机图片/random-name.png

但现在我想将所有流量重定向到另一个域.. 所以我想要这样的请求:-

  • create.domain.com/create/wf/pix/random-name1.png
  • create.domain.com/create/wf/pix
  • create.domain.com/create/wf
  • create.domain.com/create
  • create.domain.com

重定向到 domain2.com

我怎么能用 htaccess 做到这一点?

【问题讨论】:

    标签: php .htaccess redirect mod-rewrite


    【解决方案1】:

    这就是我可能的工作..请检查.. 重写引擎开启

    RewriteCond %{HTTP_HOST} create.domain\.com\create\wf\pix\ [NC]
    RewriteRule (.*) http://domain2.com/$1 [R=301,L]
    

    确保 RewriteEngine 开启

    # BEGIN Redirect
    <IfModule mod_rewrite.c>
    Options +FollowSymLinks
    RewriteEngine on
    RewriteCond %{HTTP_HOST} create.domain\.com\create\wf\pix\ [NC]
    RewriteRule (.*) http://domain2.com/$1 [R=301,L]
    </IfModule>
    

    【讨论】:

    • 是的,我有......这是我到目前为止所做的并让它工作......我使用了 cPanel 子域重定向,它为我创建了 htaccess 文件,然后我重新创建了文件夹和将 htaccess 文件放入每个文件中……但必须有更好、更智能的方法……
    • 您希望目录样式在每个域中都相同,还是希望所有图像都在新域的根目录中
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-03-16
    • 2020-05-26
    • 2020-05-04
    • 1970-01-01
    • 2016-03-26
    • 2017-05-18
    • 2011-06-29
    相关资源
    最近更新 更多