WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Redirect subdomain URL path to main domain (and keeping exact URL path) (6 posts)

  1. jaffamonkey
    Member
    Posted 1 year ago #

    I have been going round in circles on forums with this one ...

    I want to have redirect going from

    http://blog.domain.com/2013/09/01/blog-post
    to map to
    http://domain.com/2013/09/01/blog-post

    Is this possible using the NOBLOGREDIRECT or htaccess rules?

  2. jaffamonkey
    Member
    Posted 1 year ago #

    Most solutions posted only redirect to the the domain, not with full path.

  3. 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]
  4. jaffamonkey
    Member
    Posted 1 year ago #

    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>
  5. 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>
  6. jaffamonkey
    Member
    Posted 1 year ago #

    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

Topic Closed

This topic has been closed to new replies.

About this Topic