Solved

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

Posted on 2014-01-08
4
234 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

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…
If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

751 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