How do I map domains and domain/subdirectories to my wordpress installation?

Hi there,
I have recently consolidated two hosting accounts onto one account and one installation of worpress (www.onedamnthing.org.uk).

The 'other' domain was http://www.ictforlearning.org.uk. On this installation (now defunct) I had several 'sites', running off the same installation, as subdirectory sites, e.g.
http://www.ictforlearning.org.uk/italy

I have 'parked' the ictforlearning.org.uk site, and used MU plugin to map the domain to the onedamnthing.org.uk installation, created new subsites (using sub directories) with the same names as on the old 'ictforlearning.org.uk' domain.

In short, I was hoping that if a user typed in 'ictforlearning.org.uk/italy/' they would be sent to onedamnthing.org.uk/italy (with or without www), and get a seamless transition to the new domain.

This doesn't seem to be happening :slight_smile:

Sorry for the long post, could you please help!?

thanks

Ed. Podesta

  • Jack Kitterhing
    • Code Norris

    Hi there @Ed

    Hope your well today and thank you for your question.

    Could you paste .htaccess here please?

    So we're looking for redirection of the old domain to the new domain with the sub dirs?

    If this is the case, the best way to do this would be if we setup some custom .htaccess rules that are 301 redirects :slight_smile:

    Please advise.

    Thanks!

    Kind Regards
    Jack.

  • Ed
    • WPMU DEV Initiate

    Hi Jack,

    thanks for the very quick reply.

    I think this is what you mean:

    RewriteEngine on

    DirectoryIndex index.html.var index.htm index.html index.shtml index.xhtml index.wml index.perl index.pl index.plx index.ppl index.cgi index.jsp index.js index.jp index.php4 index.php3 index.php index.phtml default.htm default.html home.htm index.php5 Default.html Default.htm home.html

    # BEGIN WordPress
    RewriteBase /
    RewriteRule ^index\.php$ - [L]

    # uploaded files
    RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]

    # add a trailing slash to /wp-admin
    RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]

    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ - [L]
    RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
    RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
    RewriteRule . index.php [L]
    # END WordPress

  • Jack Kitterhing
    • Code Norris

    Hi there @Ed

    Thanks for the additional information, that's what I wanted :slight_smile:

    Now if I have this correct, try

    Options +FollowSymLinks
    RewriteEngine On
    RewriteCond %{REQUEST_URI} ^/subdirnamehere/(.*)$
    RewriteRule ^(.*) http://www.yournewdomain.com/%1 [R=302,NC]

    You'll need that for each sub domain, try that first and if it breaks anything or causes a loop, let me know, remove it and I'll re-check :slight_smile:

    Kind Regards
    Jack.

  • Ed
    • WPMU DEV Initiate

    Hi Jack,

    thanks for this - I think I understand, but I have a couple of questions.

    1 - you write 'www.yournewdomain.com', but neither of my domains is new. Do you mean onedamnthing.org.uk (the domain associated with the hosting account that I'm continuing to use) or ictforlearning.org.uk (the domain associated with the deleted hosting account, and from which I'm migrating sites)?

    2 - I need to do this for each 'subdomain' - I think that this just a typo on your part, but I need to make sure, - I'm using a subdirectory set up.

    3 - Where in my .htaccess file should this go? I'm presuming that it should not replace the whole thing. perhaps after the 'wordpress ends' bit?

    thanks, again, for all your help

    Ed.

  • Jack Kitterhing
    • Code Norris

    Hi there Ed,

    Hope your well today, sorry about the delay.

    1: Sorry, I mean the onedamnthing.org.uk domain :slight_smile:

    2: Yep, that was a typo, I thought I edited that out, sorry for the confusion! :slight_smile:

    3: You can add that just before the begin WordPress bit, or after the end part, I tested it both wells in mine and it worked either way :slight_smile:

    Thanks!

    Kind Regards
    Jack.

  • Ed
    • WPMU DEV Initiate

    Hi there, thanks for getting back to me.

    I've tried it like so:

    Options +FollowSymLinks
    RewriteEngine On
    RewriteCond %{REQUEST_URI} ^/italy/(.*)$
    RewriteRule ^(.*) http://www.onedamnthing.org.uk/%1 [R=302,NC]

    and I was hoping that that requests for 'ictforlearning.org.uk/italy' would resolve to
    'onedamnthing.org.uk/italy'

    This doesn't seem to work though. Instead such requests go to 'onedamnthing.org.uk/'

    Any idea what I'm doing wrong?

  • Ed
    • WPMU DEV Initiate

    Hiya,

    doing a little digging, and it seems that something is happening at the server end when I save the .htaccess file

    when I look the code has been changed to

    # For security reasons, Option followsymlinks cannot be overridden.
    #Options +FollowSymLinks
    Options +SymLinksIfOwnerMatch
    RewriteEngine On
    RewriteCond %{REQUEST_URI} ^/italy/(.*)$
    RewriteRule ^(.*) http://www.onedamnthing.org.uk/%1 [R=302,NC]

  • Ed
    • WPMU DEV Initiate

    Hi Jack I think I've worked it out - had a look on a few forums and used your code as the basis for this:

    RewriteCond %{HTTP_HOST} ^ictforlearning\.org\.uk$ [OR]
    RewriteCond %{HTTP_HOST} ^www\.ictforlearning\.org\.uk$
    RewriteRule ^(.*)$ "http\:\/\/www\.onedamnthing\.org\.uk\/$1" [R=301,L]

    which redirects all ictforlearning traffic with a wildcard (I think!), so the effect is the same for every ictforlearning.org.uk/ subdirectory.

    For the other domains I used domain mapping in wordpress, and this seems to be working too.

    I'm with Justhost, but I think that not allowing symlinks in this way is quite common with other hosts too, from what I read in the forums yesterday.

    thanks for your help - I'll be back if it goes wrong !

    Ed.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.