1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

[HOW] Redirect OLD URLs to new URLs for a dynamic CMS driven site

Discussion in 'Apache' started by Mr Goldberg, Mar 7, 2009.

  1. #1
    I have my company website done in Joomla CMS and the URLs are automatically generated by a component called ARTIO SEF.
    Since ARTIO SEF has been very bad these days and it slows down the whole website, im planning to use a new SEF component now,which will regenerate the whole site's URL structure again. :rolleyes:

    My site is very well known in Google and it brings me a hell lot of traffic and customers as well,so I dont want to mess up with my OLD URLs,which are indexed and pulls the clients...

    So,im looking for a good trick,by which the existing URLs which are still indexed and in Google cache,it should take the visitor to the new URL of that page only which is now with a new URL structure..

    Since,its a big site, 301 htacccess trick is not going to work..

    Whats the best way to do it ??
     
    Mr Goldberg, Mar 7, 2009 IP
  2. Ladadadada

    Ladadadada Peon

    Messages:
    382
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Why do you think that a 301 is not the right way to handle this ?

    I have used and continue to use 301 redirects on sites that are much larger than anything Joomla can handle. I'm absolutely sure that a 301 is the best solution.

    If it were up to me, I would put a 301 redirect in my httpd.conf that redirected from the old URL to the new one. Actually, I would write a single rule that redirected all of the old URLs to the new URLs.

    If you are dead certain that you can't use a 301, you can do HTTP-EQUIV redirects which are handled in the HTML of the old web page. As the WikiPedia page says, you could also use JavaScript on the page itself instead of the meta refresh. Both of these methods require that you keep the old page up and running but add some content to it so that visitors are redirected to the new page. Once the PageRank has transferred across and most visitors are hitting the new page directly you can take it down.

    Nonetheless, I would strongly recommend creating a rewrite rule that redirected all users from old pages to new pages using 301 redirects and leaving it there forever.
     
    Ladadadada, Mar 14, 2009 IP
  3. Mr Goldberg

    Mr Goldberg Banned

    Messages:
    651
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Yeah,I just want all of my OLD URLs to point to my newly generated URLs..
    What do you suggest ?
     
    Mr Goldberg, Mar 14, 2009 IP
  4. Ladadadada

    Ladadadada Peon

    Messages:
    382
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Do your old URLs and your new URLs follow a pattern ?

    Could you paste some of them here ? Five or six of each would be good, don't worry about the domain or the http:// part. If they follow a pattern, we can help make a single rule that will do all the redirects for you.
     
    Ladadadada, Mar 17, 2009 IP
  5. Mr Goldberg

    Mr Goldberg Banned

    Messages:
    651
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Both the OLD and NEW URLs are almost going to be same.. May be just 1-2 characters difference,or else completely same..
     
    Mr Goldberg, Mar 17, 2009 IP
  6. Ladadadada

    Ladadadada Peon

    Messages:
    382
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    0
    #6
    That sounds perfect for mod_rewrite to handle.

    What you need is a file called .htaccess in the root folder of your website.
    In this file you need to put something like this:
    RewriteRule ^/?blog/([a-z0-9])+ /articles/$1 [R=301,NC,L]
    Code (markup):
    What this will do is make any request that starts with "/blog/" (your old URLs) will be redirected to the same thing but with "/articles/" (your new URLs) instead of "/blog/".

    The part in parentheses will match any string of at least one or more numbers and letters. (The plus + means "one or more of the previous block". The brackets [] mean "anything in this range".) Then, whatever it matches will be available in the second part as $1. i.e Whatever comes after "/blog/" will end up after "/articles/". Regular expressions can get much more complicated than this but I suspect for your needs, something like this will probably do just fine. The trick is to make sure that the first matches all of the old URLs and nothing else and that the second part matches all of the new URLs.

    The bit at the end means [R=301] (Send back a 301 redirect), [NC] (Don't care about upper and lower case) and [L] (Make this the last rewrite rule. Don't do any more after this one.)

    Of course, I'm just guessing here about what your old and new URLs look like. You will have to modify the regular expression yourself so that it actually matches your URLs or paste us some examples of the old and new URLs here.

    I wrote an Apache Regular Expression guide a little while ago that goes through all of the available meta characters (The special ones like * and + and []) and how you can use them to match various different strings which might prove helpful if you want to write the regex yourself.
     
    Ladadadada, Mar 17, 2009 IP
    Mr Goldberg likes this.
  7. Mr Goldberg

    Mr Goldberg Banned

    Messages:
    651
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Mr Goldberg, Mar 17, 2009 IP