• Resolved Antipole

    (@antipole)


    I have found lots of advice and recipes for achieving the redirection I need, but often there are comments that it did not work right.

    I have a multisite installation (without sites in sub-folders) which includes the site http://mg30.antipole.co.uk. This one site has now been moved away to its own WordPress installation (non-multisite) at a different URL http://mg30.org.uk and is working there.

    I need to establish redirects so that anyone trying to go to the old URL http://mg30.antipole.co.uk ends up at http://mg30.org.uk and preferably the same point in the substructure. I think I need 301 redirects so that the existing Google ranking is retained.

    I have already tried the Redirect plugin and it has put some relevant stuff in my .htaccess file but it is not redirecting. I note that the mg30-specific RewriteCond /RewriteRule is after the general rules – might this be a problem? I am reluctant to mess with the file myself unless I am certain of what I am doing as it is a live site. (There is not much traffic and so redirecting within a plugin would also be viable if that was a better way to go, but the only ones I have seen for multisite look complicated to configure.)

    Can someone please advise?

    .htaccess as it is today:

    # BEGIN All In One WP Security
    #AIOWPS_BLOCK_SPAMBOTS_START
    <IfModule mod_rewrite.c>
    RewriteCond %{REQUEST_METHOD} POST
    RewriteCond %{REQUEST_URI} ^(.*)?wp-comments-post\.php(.*)$
    RewriteCond %{HTTP_REFERER} !^http(s)?://mg30\.antipole\.co\.uk [NC,OR]
    RewriteCond %{HTTP_USER_AGENT} ^$
    RewriteRule .* http://127.0.0.1 [L]
    </IfModule>
    #AIOWPS_BLOCK_SPAMBOTS_END
    # END All In One WP Security
    
    RewriteEngine On
    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).*) $1 [L]
    # RewriteRule  ^[_0-9a-zA-Z-]+/(.*\.php)$ $1 [L]
    RewriteRule . index.php [L]
    
    RewriteCond %{HTTP_HOST} ^mg30\.antipole\.co\.uk$ [OR]
    RewriteCond %{HTTP_HOST} ^www\.mg30\.antipole\.co\.uk$
    RewriteRule ^/?$ "http\:\/\/mg30\.org\.uk\/" [R=301,L]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Your rewrite rule is close. But you lose the path and file. And yes you should put it at the top. All rewrite rules should be contained within the IfModule directives.

    My guess is you want something like this. Disclaimer – I did not test it:

    RewriteCond %{HTTP_HOST} ^mg30\.antipole\.co\.uk$ [OR]
    RewriteCond %{HTTP_HOST} ^www\.mg30\.antipole\.co\.uk$
    RewriteRule ^.*$ "http\:\/\/mg30\.org\.uk\/$1" [R=301,L]

    Those rules should cause requests for http://mg30.antipole.co.uk/somepath/somefile to 301 redirect to http://mg30.org.uk/somepath/somefile

    Recommendation: Backup your original .htaccess file

    Thread Starter Antipole

    (@antipole)

    @jkhongusc – thank you for responding.
    I have copies your lines straight out of your email and put them near the top and removed the earlier mg30 stuff at the bottom.
    But still no effect – no redirection. I have checked that the .htaccess file has indeed been updated.
    Any further help would be much appreciated – I am not competent in .htaccess language. I include below the updated file.
    thanks

    # BEGIN All In One WP Security
    #AIOWPS_BLOCK_SPAMBOTS_START
    <IfModule mod_rewrite.c>
    RewriteCond %{REQUEST_METHOD} POST
    RewriteCond %{HTTP_HOST} ^mg30\.antipole\.co\.uk$ [OR]
    RewriteCond %{HTTP_HOST} ^www\.mg30\.antipole\.co\.uk$
    RewriteRule ^.*$ &quot;http\:\/\/mg30\.org\.uk\/$1&quot; [R=301,L]
    RewriteCond %{REQUEST_URI} ^(.*)?wp-comments-post\.php(.*)$
    RewriteCond %{HTTP_USER_AGENT} ^$
    RewriteRule .* http://127.0.0.1 [L]
    </IfModule>
    #AIOWPS_BLOCK_SPAMBOTS_END
    # END All In One WP Security
    
    RewriteEngine On
    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).*) $1 [L]
    # RewriteRule  ^[_0-9a-zA-Z-]+/(.*\.php)$ $1 [L]
    RewriteRule . index.php [L]

    You have things in the wrong order and a copy-n-paste error. I also had an error, missing a set of parenthesis. This should work:

    <IfModule mod_rewrite.c>
    RewriteCond %{HTTP_HOST} ^mg30\.antipole\.co\.uk$ [OR]
    RewriteCond %{HTTP_HOST} ^www\.mg30\.antipole\.co\.uk$
    RewriteRule ^(.*)$ "http\:\/\/mg30\.org\.uk\/$1" [R=301,L]
    </IfModule>
    
    # BEGIN All In One WP Security
    #AIOWPS_BLOCK_SPAMBOTS_START
    <IfModule mod_rewrite.c>
    RewriteCond %{REQUEST_METHOD} POST
    RewriteCond %{REQUEST_URI} ^(.*)?wp-comments-post\.php(.*)$
    RewriteCond %{HTTP_USER_AGENT} ^$
    RewriteRule .* http://127.0.0.1 [L]
    </IfModule>
    #AIOWPS_BLOCK_SPAMBOTS_END
    # END All In One WP Security
    
    <IfModule mod_rewrite.c>
    RewriteEngine On
    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).*) $1 [L]
    # RewriteRule  ^[_0-9a-zA-Z-]+/(.*\.php)$ $1 [L]
    RewriteRule . index.php [L]
    </IfModule>
    Thread Starter Antipole

    (@antipole)

    @jkhongusc Yep – that’s working now.

    Thank you very much for your time and trouble – I really appreciate it.

    Tony

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Request for help re redirection from multi site site’ is closed to new replies.