Solved

htaccess redirect problem

Posted on 2011-09-22
2
306 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 500 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
The viewer will learn how to count occurrences of each item in an array.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

734 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