• Hi,

    I want to add a Redirect line on my main WordPress Multisite blog’s .htaccess file, intended for one of the other Multisite blogs. How can I do this?

    If there’s no way to do it, can I add domain records or something like that, to do the trick? Thanks, guys.

Viewing 12 replies - 1 through 12 (of 12 total)
  • Here’s a tutorial on rewrites: https://www.webforgers.net/mod-rewrite/mod-rewrite-syntax.php

    Also, if you give us more info, we might be able to point out a specific rule. For example, telling us you want to point mysite.com to myothersite.org would allow us to give you the specific rule structure needed.

    Thread Starter joaoramos

    (@joaoramos)

    Oh, in my case it’s just a simple Redirect. It would be something like this: Redirect https://ntc-ua.com/directorio https://ntc-ua.com/files/directorio/index.php

    And now what? Should I add this line on my main Multisite blog’s .htaccess? You see, https://joaoramos.org is my main blog and https://ntc-ua.com/ is one of the Multisite blogs. How can I do that?

    Yes, you can put a blog-specific rewrite in the main htaccess file (there’s only one).

    Thread Starter joaoramos

    (@joaoramos)

    Yes, but I’ve already tried it that way and it doesn’t work. When I hit https://ntc-ua.com/directorio it should send me to https://ntc-ua.com/files/directorio/index.php but instead it gives me a WP 404.

    Any suggestions? This is my current .htaccess: https://pastie.org/1966072.

    I think this is a job for… Super Ipstenu!

    Thread Starter joaoramos

    (@joaoramos)

    How should I contact Ipstenu? Should I promise him/her pralines as well? ??

    Her… and she should see this thread..

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    ?????? Advisor and Activist

    Wait till she wakes up ?? (Had a flight from hell on Sunday.)

    The trick is to put any non-WordPress htaccess things ABOVE WordPress’s calls ??

    Another thing is you probably want https://ntc-ua.com/directorio/ANYTHING to go to the https://ntc-ua.com/files/directorio/index.php page so I made a change to that to allow wildcards.

    Last, https://ntc-ua.com/files/directorio/index.php and https://ntc-ua.com/files/directorio/ should be the same (right now, non index.php gives a 404). You should be able to handle that with DirectoryIndex index.php index.html at the top of your .htaccess

    # Directory index
    DirectoryIndex index.php index.html
    
    # Security hacks
    Options -Indexes
    
    <files wp-config.php>
    	order allow,deny
    	deny from all
    </files>
    
    <IfModule mod_rewrite.c>
    RewriteEngine on
            # BEGIN Anti Script Injection
            Options +FollowSymLinks
            RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
            RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
            RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
            RewriteRule ^(.*)$ index.php [F,L]
            # END Anti Script Injection
    </IfModule>
    
    RewriteRule ^directorio/(.*)$ https://ntc-ua.com/files/directorio/ [L,R=301]
    
    # BEGIN WordPress
    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]
    # END WordPress
    Thread Starter joaoramos

    (@joaoramos)

    Thanks, Ipstenu. Unfortunately, it didn’t work ?? I had to roll back to this .htaccess setup:

    [Code moderated as per the Forum Rules. Please use the pastebin]

    Is it possible to target https://ntc-ua.com only, for the redirect? Thanks for your time ??

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    ?????? Advisor and Activist

    Depends what you mean by ‘target’… Are you using domain mapping or something?

    Thread Starter joaoramos

    (@joaoramos)

    Yeah, I’m using MU Domain Mapping. Is it bad news?

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    ?????? Advisor and Activist

    (Hey, whomever modded his .htaccess, it wasn’t THAT long! And now I don’t have it anymore…)

    No, not at all ?? Just had to know what I was working with ?? Should be something like this:

    RewriteCond %{HTTP_HOST} ^ntc-ua.com [OR]
    RewriteCond %{HTTP_HOST} ^www.ntc-ua.com
    RewriteRule ^/directorio/(.*)$ https://ntc-ua.com/files/directorio/index.php [R=301,L]

    Which says ONLY if someone is coming from ntc-ua (or https://www.ntc-ua) should we redirect /directorio to this other place.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘How to setup .htaccess redirects?’ is closed to new replies.