Solved

htaccess redirect problem

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

In Solr 4.0 it is possible to atomically (or partially) update individual fields in a document. This article will show the operations possible for atomic updating as well as setting up your Solr instance to be able to perform the actions. One major …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

809 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