The MU forums have moved to WordPress.org

Interesting .htaccess (ModRewrite) challenge. (2 posts)

  1. taylhis
    Member
    Posted 14 years ago #

    Here is my current .htaccess file:

    RewriteEngine On
    RewriteBase /
    
    #uploaded files
    RewriteRule ^(.*/)?files/$ index.php [L]
    RewriteRule ^(.*/)?files/(.*) wp-content/blogs.php?file=$2 [L]
    
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule . - [L]
    RewriteRule  ^([_0-9a-zA-Z-]+/)?(wp-.*) $2 [L]
    RewriteRule  ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
    RewriteRule . index.php [L]

    Everything works fine -- all subdirs, etc...

    The problem is I have installed regular wordpress in a subdir

    mysite.com/newblog

    I want the htaccess file to redirect requests to JUST the homepage (http://mysite.com or http://www.mysite.com) to the subdirectory. But only direct to the homepage.

    So, http://www.mysite.com (or mysite.com) would redirect to mysite.com/newblog but xyz.mysite.com would still work for the blogs which are setup to use subdomains. Also, for example, http://www.mysite.com/wp-admin would NOT redirect to http://www.mysite.com/newblog/wp-admin but would stay in the correct subdir.

    A bit confused?

    simply -- I want only visits to my HOMEPAGE with WWW or NO SUBDOMAIN redirected to a sub directory.

  2. dgilmour
    Member
    Posted 14 years ago #

    In the .htaccess file in the root directory of http://mysite.com, insert a Redirect rule to redirect index.html to mysite.com/newblog, like this:

    Redirect /index.html http://mysite.com/newblog

    You'll need to make sure that any existing index.html is renamed out of the way, of course.

About this Topic

  • Started 14 years ago by taylhis
  • Latest reply from dgilmour