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.

Complicated 301 Redirect conundrum

Discussion in 'Apache' started by Jaimitodelqueso, Jul 14, 2005.

  1. #1
    Hi,

    How do I redirect all root directory urls (i.e. xxx.com/filename.htm, etc...) to another domain (xxx.com.au/filename.htm, whilst maintaining subfolders/directories on the original domain (xxx.com/foldername/filename.htm)? and preferrably without having to write htaccess for every page!

    Thanks
    (hope I was clear)
     
    Jaimitodelqueso, Jul 14, 2005 IP
  2. Old Welsh Guy

    Old Welsh Guy Notable Member

    Messages:
    2,699
    Likes Received:
    291
    Best Answers:
    0
    Trophy Points:
    205
    #2
    Options +FollowSymLinks
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^yourdomain\.com
    RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [R=permanent,L]

    This is a mod rewrite that will transfer any request from one domain to the othre. It is set up here to send non www requests to www.domain.com
     
    Old Welsh Guy, Jul 14, 2005 IP
  3. Jaimitodelqueso

    Jaimitodelqueso Peon

    Messages:
    48
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hello Old Welsh Guy,

    Thanks for your reply. I am not quite if I have understood/made myself understood!

    If I understand, this will route requests where the person has omitted to type www.

    However, my problem is that I wish to push all requests permanently from w-w.xxx.com/filename.htm to w-w.xxx.com.au/filename.htm, whilst leaving any subfolders on w-w.xxx.com intact (w-w.xxx.com/foldername/filename.htm)

    I did see a bit of code along the lines of what you posted:

    RewriteEngine on
    RewriteRule ^/~(.+) h-p://newserver/~$1 [R,L]

    changed the http as can't post links. Is this relevant?

    btw, your signtaure reminds me of my father's favourite adage:' there are old men and there are bold men, but there are very few old bold men"!
     
    Jaimitodelqueso, Jul 14, 2005 IP
  4. johnt

    johnt Peon

    Messages:
    178
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Something along the lines of the following should work ( I think )

    RewriteEngine on
    RewriteCond %{HTTP_HOST} www.xxx.com
    RewriteCond %{REQUEST_URI} ^/([^/]*)$
    RewriteRule ^(.*)$ http://www.xxx.com.au/$1 [R=permanent,L]

    Basically you want to find request filenames which don't have a / in them - i.e. everything that's in the root folder. The syntax may not be spot on but I think its close.

    hope it helps

    John
     
    johnt, Jul 14, 2005 IP
  5. Jaimitodelqueso

    Jaimitodelqueso Peon

    Messages:
    48
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Spot on! It was hard enough just to explain, let alone hope to resolve. I'll test it on unused domains before going live.Thank you so much.
     
    Jaimitodelqueso, Jul 14, 2005 IP