Can I use .htaccess rules using wildcard for site, followed by rewrites for specific pages?

Viewed 52

I am trying to permanently redirect an entire site, where approx. 130 links remain the same except for the new domain, and then approx. 20 links have to be redirected by file name. I cannot get code to do both.

I have this beginning on the first line of my htaccess page:

RewriteEngine on
RewriteRule ^resources$ http://www.thelastdancer.com/blog? [R=301,L]
RewriteRule ^(.*)$ https://thelastdancer.com/$1 [R=301,L]

I can get the second rule to work - all my articles redirect perfectly when the /pagetitle matches. I cannot get the singe pages to redirect: https://balletforadults.com/resources SHOULD OPEN TO https://thelastdancer.com/blog I have also tried putting the first rule in the second position, no luck.

Thanks for any guidance - I have been searching through mountains of redirect code, and can't get anything to work.

1 Answers

Could you please try following Rules, written based on your shown samples. We need to use RewriteCond here to check from which domain(host) name request is coming from and then accordingly redirecting request from bal.... to thelasdancer domain.

RewriteEngine ON
RewriteCond  %{HTTP_HOST} balletforadults\.com [NC]
RewriteRule ^resources/?$ http://thelastdancer.com/blog [R=301,L]
Related