Reputation: 841
I would like to redirect just one page to another page on the same site
Does this pattern look correct?
Redirect 301 https://subdomain.domain.com/old-page-name https://subdomain.domain.com/new-page-name
The reason I ask is that I have found various examples of redirecting just a single page but they look like this:
Redirect 301 /old-page-name http://www.your-domain.com/new-page-name
If I do it like this and the domain has multiple subdomains is that going to cause an issue and redirect all subdomain sites with that matching url? or is there one .htaccess file per subdomain for example
So to add to the question, if I wanted a second page to redirect the syntax would look like this?:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^subdomain\.domain\.co\.uk$ [NC]
RewriteRule ^/oldpage01 https://%{HTTP_HOST}/newpage01 [NC,R=301,L]
RewriteRule ^/oldpage02 https://%{HTTP_HOST}/newpage02 [NC,R=301,L]
I could just list a whole bunch like that?
Upvotes: 0
Views: 110
Reputation: 786271
You should be using mod_rewrite rule for this to target only one subdomain. Place this in root .htaccess:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^subdomain\.domain\.com$ [NC]
RewriteRule ^old-page-name https://%{HTTP_HOST}/new-page-name [NC,R=301,L]
EDIT: Based on your edited question you can use this code:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^subdomain\.domain\.co\.uk$ [NC]
RewriteRule ^oldpage01 https://%{HTTP_HOST}/newpage01 [NC,R=301,L]
RewriteCond %{HTTP_HOST} ^subdomain\.domain\.co\.uk$ [NC]
RewriteRule ^oldpage02 https://%{HTTP_HOST}/newpage02 [NC,R=301,L]
Upvotes: 0