?
Solved

htaccess redirect problem

Posted on 2011-09-22
2
Medium Priority
?
320 Views
Last Modified: 2012-05-12
I am changing domain names.

I have a set of pages in which the url of the page changes, in addition to the domain name change.

Then the rest of the site just needs to redirect to the new domain using the existing paths.

I thought I could do something like this:

-------------------------------------------------------

Options +FollowSymLinks
RewriteEngine on

#redirect these individual pages
Redirect 301 /name1/3676743/ http://www.newname.com/name1/3676768/ 
Redirect 301 /name2/3676739/ http://www.newname.com/name2/3676766/ 
Redirect 301 /name3/3676741/ http://www.newname.com/newname3/3676767/ 

#redirect remaining pages keeping current paths
RewriteRule (.*) http://www.newname.com/$1 [R=301,L]

-----------------------------------------------

If I don't include the last line, the redirects work ok

If I include the last line though, it seems that's the line that is used, the redirects are ignored and just the last line used, so clicks end up on the wrong pages.

I somehow need to have the redirects used first, then the last line.

Any help on how to do this would be very appreciated :)

Chris
0
Comment
Question by:St_Aug_Beach_Bum
[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 Comments
 
LVL 12

Accepted Solution

by:
larsrohr earned 2000 total points
ID: 36585138
Instead of mixing Redirect and RewriteRule directives, why not just use RewriteRules:

#redirect these individual pages
RewriteRule ^/name1/3676743/$ http://www.newname.com/name1/3676768/ [R=301,L]
RewriteRule ^/name2/3676739/$ http://www.newname.com/name2/3676766/ [R=301,L]
RewriteRule ^/name3/3676741/$ http://www.newname.com/newname3/3676767/ [R=301,L]

#redirect remaining pages keeping current paths
RewriteRule (.*) http://www.newname.com/$1 [R=301,L]
0
 

Author Closing Comment

by:St_Aug_Beach_Bum
ID: 36588426
That works!

Thank you,

Chris
0

Featured Post

WordPress Tutorial 3: Plugins, Themes, and Widgets

The three most common changes you will make to your website involve the look (themes), the functionality (plugins), and modular elements (widgets).

In this article we will briefly define each again, and give you directions on how to install them.

Question has a verified solution.

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

Shoutout to Emily Plummer (http://www.experts-exchange.com/members/eplummer26.html) for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
The viewer will learn how to count occurrences of each item in an array.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Suggested Courses

765 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