Forum Moderators: phranque

Message Too Old, No Replies

Questions about redirecting with .htaccess

Site redesign redirect questions

         

waseemni

11:38 am on Mar 24, 2010 (gmt 0)

10+ Year Member



Hi,

We have moved to a new website that has a completely different strucutre than the old one. I am doing redirects using .htaccess.

I'm very new to .htaccess and despite a lot of reading, I still have 2 main difficulties:

1- If I redirect a main folder to a new url, all subfolders under the main old folder also automatically go to the same new url. I added a specific redirect url to the subfolder, but that did not help. So, in short, how I can do this redirec:
.com/old1 -> .com/new1
.com/old1/subold1 -> .com/new2

becuase just using 2 typical redirect lines just doesn't do it.

2- The site offers multiple languages. On our old website we used this language strategy: each language had its own domain. So english had a co.uk domain, french had a .fr domain. The new site uses a different strategy .com/en .com/fr. But in the back, it was 1 server and 1 database.
So, using 1 .htaccess, how can I do such redirects?

g1smd

12:09 pm on Mar 24, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Make the patterns more 'exact'. You'll find the ^start and end$ anchors useful. That's the power of regular expressions and mod_rewrite.

Further comments after you provide some code to discuss.

waseemni

12:53 pm on Mar 24, 2010 (gmt 0)

10+ Year Member



g1smd, thank you for replying. To be more detailed, this is one of the cases I have:

Redirect 1 /en/multimedia to mydomain.com/en/c/1/office/8/multimedia.aspx

Redirect 2 en/multimedia/headphones to mydomain.com/en/c/40/leisure-relax/45/multimedia.aspx

what is happening now is that the multimedia/headphones is redirected to the 1st url.

jdMorgan

1:04 pm on Mar 26, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Put your directives in order from most-specific patterns and condition to least-specific. Because your second redirect 'begins with' the same path as your first, the first one will always be invoked before the second can be applied. Therefore, the second directive will never be applied.

Jim

waseemni

1:41 pm on Mar 26, 2010 (gmt 0)

10+ Year Member



Thank you Morgan. Your tip worked just fine.

Does anyone have an idea how do I also solve the redirections from the different domains?

The english version of the website uses the domain co.uk and the French .fr and so on. But when I do redirects from the old website, I only refer to what comes after the "/".

jdMorgan

2:35 pm on Mar 26, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In order for this thread to be productive, we need to see the relevant sections your code and we need solid examples of the URL-paths you wish to handle and the filepaths to which those URL-paths are to resolve.

Jim