Solved

htaccess to redirect a number of pages from one domain to another - wildcards?

Posted on 2014-01-08
4
230 Views
Last Modified: 2014-01-27
Hello

I have a number of pages that start with the same words in the file name that I want to redirect to another domain.

Example:

http://www.olddomain.com/fruits-that-taste-good
http://www.olddomain.com/fruits-that-taste-bad
http://www.olddomain.com/fruits-that-taste-sweet
http://www.olddomain.com/fruits-that-taste-sour

I want to do a 301 redirect to the following
http://www.newdomain.com/fruits-that-taste-good
http://www.newomain.com/fruits-that-taste-bad
http://www.newdomain.com/fruits-that-taste-sweet
http://www.newdomain.com/fruits-that-taste-sour


Is there a way to do a rule that will take the wild card "fruits-that-taste-*" and direct all of those to the new domain -- without having to type each page

Something like this (of course I am not using the right syntax:

Redirect 301 http://www.olddomain.com/fruits-that-taste-* http://www.newdomain.com/*

Not sure if this is at all possible.  Looking at my existing htaccess file I see that it is already using RewriteRule for other items.  I read somewhere that RewriteRule is used for more elaborate directs.  So it is available if it helps with this solution.

Thanks!

Rowby
0
Comment
Question by:Rowby Goren
  • 2
  • 2
4 Comments
 
LVL 13

Accepted Solution

by:
duncanb7 earned 500 total points
ID: 39765650
Could your try this from redirecting site of  sitea to siteb on your .htaccess. file  ?

RewriteEngine On
RewriteCond %{HTTP_HOST} ^.*sitea.com$ [NC]
RewriteRule ^(.*)$ http://siteb.com/$1 [R=301,L]


Duncan
0
 
LVL 9

Author Comment

by:Rowby Goren
ID: 39765854
Hi Duncak.

Thanks  I will do the test and get back to you later today.

Rowby
0
 
LVL 9

Author Closing Comment

by:Rowby Goren
ID: 39810109
Hi Duncan,

Thanks for the answer.  Sorry for the delay in awarding points.

Rowby
0
 
LVL 13

Expert Comment

by:duncanb7
ID: 39811669
thanks for your pt,

Have a nice day

Duncan
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In my time as an SEO for the last 2 years and in the questions I have assisted with on here I have always seen the need to redirect from non-www urls to their www versions. For instance redirecting http://domain.com (http://domain.com) to http…
Over the last year I have answered a couple of basic URL rewriting questions several times so I thought I might as well have a stab at: explaining the basics, providing a few useful links and consolidating some of the most common queries into a sing…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

27 Experts available now in Live!

Get 1:1 Help Now