Complicated site restructuring and 301's to accompany it - need help!

Discussion in 'Apache' started by SupaMonkey, Jan 25, 2008.

  1. #1
    Hey guys,
    I just finished re-designing my whole site. I used to have subdomains for subsections of my site and I want to do away with that and go to directories.

    I used to have:
    1) subdomain.whatever.com
    2) subdomain.whatever.com/index.php?section=somepage

    Now I want to have it redirected
    1) www.whatever.com/some_new_folder_name
    2) www.whatever.com/some_new_folder_name/1-a_completely_new_page_name.htm


    This is what I have - Im really stuck when it comes to (2):
    Options +FollowSymLinks 
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^hosting.osirion.co.za [NC] 
    RewriteRule ^(.*)$ http://www.osirion.co.za/web_hosting/ [L,R=301] 
    
    Code (markup):
    Please help! You can also suggest how to fix the above if its un-optimal/wrong :p THANKS!
     
    SupaMonkey, Jan 25, 2008 IP
  2. ilovelinux

    ilovelinux Peon

    Messages:
    285
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #2
    ilovelinux, Jan 26, 2008 IP
  3. SupaMonkey

    SupaMonkey Peon

    Messages:
    134
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Yeah, (1) isnt the problem - (2) is what Im battling with :(
     
    SupaMonkey, Jan 26, 2008 IP
  4. SupaMonkey

    SupaMonkey Peon

    Messages:
    134
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I can do this for example, but this just uses the same page name - and I dont want that - I want to specify the new page name:

    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^whatever.osirion.co.za$ [OR]
    RewriteCond %{HTTP_HOST} ^www.whatever.osirion.co.za$
    RewriteRule ^(.*)$ http://www.osirion.co.za/whatever/ [R=301,L]
    Code (markup):
     
    SupaMonkey, Jan 26, 2008 IP
  5. Ladadadada

    Ladadadada Peon

    Messages:
    382
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    0
    #5
    If I understand this correctly, there is no relationship between the old URL and the new URL other than they have the same content. They have completely different names.

    The only way to do this is by maintaining a mapping of old URLs to new URLs. This can be done in the .htaccess file but manually placing a rewrite for each and every URL on the old site pointing to the new site or it can be done in a PHP file (that possibly accesses a database to make adding new URLs easier) on the old site that all pages on the old site map to with a catch-all rewrite.
    Both methods are roughly the same. One involves a bit more effort up front and less later on, the other requires less effort up front but a little more to maintain.

    Either way, you're going to have to list every old URL and every new URL that it should point to.

    You might want to re-think the design decision to make new URLs that don't look like the old ones.
     
    Ladadadada, Jan 26, 2008 IP