Solved

htaccess redirect problem

Posted on 2011-09-22
2
300 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
2 Comments
 
LVL 12

Accepted Solution

by:
larsrohr earned 500 total points
Comment Utility
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
Comment Utility
That works!

Thank you,

Chris
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Preface In the first article: A Better Website Login System (http://www.experts-exchange.com/A_2902.html) I introduced the EE Collaborative Login System and its intended purpose. In this article I will discuss some of the design consideratio…
What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
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)

728 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

9 Experts available now in Live!

Get 1:1 Help Now