How can I redirect from one subdomain to another in .htaccess?

后端 未结 2 773
抹茶落季
抹茶落季 2020-12-18 15:09

Recently we changed the name of a subdomain, now we need to redirect all the old pages to the new subdomain pages.

Example page links:

  • Old URL: http

相关标签:
2条回答
  • 2020-12-18 15:41

    This worked for me, and maintains the URI:

    RewriteCond %{HTTP_HOST} ^jquery\.webcodehelpers\.com
    RewriteRule (.*)$ http://uieiq.webcodehelpers.com/$1 [R=301,L]
    

    I used this to redirect a subdomain to another subdomain.

    0 讨论(0)
  • 2020-12-18 15:55

    Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your DOCUMENT_ROOT/.htaccess file:

    RewriteEngine On
    
    RewriteCond %{HTTP_HOST} ^jquery\.webcodehelpers\.com$ [NC]
    RewriteRule ^ http://uieiq.webcodehelpers.com%{REQUEST_URI} [L,R=301,NE]
    

    Please read: Apache mod_rewrite Introduction

    0 讨论(0)
提交回复
热议问题