Solved

htaccess redirect problem

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

The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

Question has a verified solution.

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

Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
This article will show, step by step, how to integrate R code into a R Sweave document
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

707 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