WordPress.org

Support

Support » Multisite » [Resolved] Redirect subdomain URL path to main domain (and keeping exact URL path)

[Resolved] Redirect subdomain URL path to main domain (and keeping exact URL path)

Viewing 5 replies - 1 through 5 (of 5 total)
  • Most solutions posted only redirect to the the domain, not with full path.

    You’d want to do this: http://halfelf.org/2012/htaccess-anarchy/

    RewriteCond %{HTTP_HOST} ^blog\.example\.com  [NC]
    RewriteRule ^(.*) http://example.com/$1 [L,R=301]

    That looks good, but it doesnt appear to be applying. I guess there is clash in htaccess(?). Could someone let me know where the above lines should fit in, I would be grateful. I am “googled out” on this problem 🙂

    This is my current file.

    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]
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    # END WordPress
    
    <IfModule mod_security.c>
     SecFilterEngine Off
     SecFilterScanPOST Off
    </IfModule>

    Well there’s problem one. You didn’t follow the directions of ‘replace’ the .htaccess….

    RewriteCond %{HTTP_HOST} ^blog\.example\.com  [NC]
    RewriteRule ^(.*) http://example.com/$1 [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
    
    <IfModule mod_security.c>
     SecFilterEngine Off
     SecFilterScanPOST Off
    </IfModule>

    That was current htaccess without any edit – I just wasn’t sure where to put those lines. Thankyou so much, very appreciated 🙂 It works! And I learned a little more about rewrites, so no bad thing

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Resolved] Redirect subdomain URL path to main domain (and keeping exact URL path)’ is closed to new replies.
Skip to toolbar