• Hi everyone,

    I am working with a multi-site network installation of WordPress that was set up with subdomains and has Domain Mapping on the sites.

    One of the sites just created was a static site before and in the httpd.conf on the server there was a line on the virtual host for that site like the following:

    RedirectPermanent /something “https://something.domain.com/something”

    However since this site now is part of the Multi-Site I had to move the site ServerName and all its aliases under the <VirtualHost> of the Multi Site on the httpd.conf which means the site URL and all its aliases are now ServerAlias of the WordPress Multi Site.

    How can I target that specific site URL in order to still be able to do the same type of redirect that was happening before?
    P.S On the old site there was no page called “something” it was purely if anyone typed that URL they would be redirected to the new URL.

    Thanks in Advance,

    Vitor

Viewing 5 replies - 1 through 5 (of 5 total)
  • Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    ?????? Advisor and Activist

    You can do that via .htaccess.

    If you want ANYTHING.domain.com/something/ to go to https://something.domain.com/something
    RewriteRule ^something/ https://something.domain.com/something [L,R=301]

    If you only want domain.com/something/ to go to https://something.domain.com/something

    RewriteCond %{HTTP_HOST} ^domain\.com
    RewriteRule ^something/ https://something.domain.com/something [L,R=301]

    Put ^something/(.*) instead of ^something/ if you want something/<anything> to redirect.

    Thread Starter vitorf7

    (@vitorf7)

    Hi Ipstenu,

    I tried adding that code to the .htaccess file on the root of the WordPress Multi-Site Install but when I go to the site and try to go to https://www.domain.com/something it does not redirect me to https://something.domain.com/something

    Here is the actual .htaccess code

    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    
    # uploaded files
    RewriteRule ^files/(.+) wp-includes/ms-files.php?file=$1 [L]
    
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ - [L]
    RewriteRule . index.php [L]
    
    #php_value error_reporting 7
    #php_flag display_errors On
    
    RewriteCond %{HTTP_HOST} ^domain\.com
    RewriteRule ^something/ https://something.domain.com/something [L,R=301]

    I even tried making the ^something/ into ^/something just in case but nothing worked. What do you think I may be doing wrong

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    ?????? Advisor and Activist

    Any and all .htaccess changes MUST go ABOVE the WordPress calls. Otherwise it’ll use WP’s normal 404 rules.

    when I go to the site and try to go to https://www.domain.com/something it does not redirect me to https://something.domain.com/something

    If you want that, put this:

    RewriteCond %{HTTP_HOST} ^domain\.com
    RewriteRule ^something/ https://something.domain.com/something [L,R=301]
    
    #BEGIN WORDPRESS
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    
    # uploaded files
    RewriteRule ^files/(.+) wp-includes/ms-files.php?file=$1 [L]
    
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ - [L]
    RewriteRule . index.php [L]
    # END WORDPRESS
    Thread Starter vitorf7

    (@vitorf7)

    I have done it just as you ask but unfortunately for some weird reason it does not work. When you enter the URL https://www.domain.com/something and click enter it just goes to https://www.domain.com and not https://something.domain.com/something.

    Very weird and I did exactly as you said.

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    ?????? Advisor and Activist

    Are you going to https://www.domain.com or https://domain.com?

    It does matter ?? RewriteCond %{HTTP_HOST} ^domain\.com is VERY specific.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Redirect Permanent on Blog Specific Sites’ is closed to new replies.