How can I redirect from one subdomain to another i

2020-02-11 09:41发布

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:

My findings: when I try to access the subdomain in the top level it is working good.

How can I redirect all URLs on the old subdomain to the new subdomain?

currently i have the below code in .htaccess file , please guide to solve the problem

RewriteEngine on
RewriteCond %{HTTP_HOST} ^jquery\.webcodehelpers\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.jquery\.webcodehelpers\.com$
RewriteRule ^/?$ "http\:\/\/uieiq\.webcodehelpers\.com\/search\/label\/jquery\ interview\ questions" [R=301,L]

2条回答
2楼-- · 2020-02-11 10:03

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

查看更多
来,给爷笑一个
3楼-- · 2020-02-11 10:12

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.

查看更多
登录 后发表回答