The MU forums have moved to WordPress.org

More .htaccess issues (long -winded) (3 posts)

  1. WWDay3
    Member
    Posted 15 years ago #

    I'm beginning to think the apache gods hate me. The only .htaccess change I've made so far that's worked is one my host gave be that overrides PHP4 to PHP5.

    Issue #1:

    The other day I was perusing webmaster.com and I found a thread for overriding a "generic" subdomain to a same-named subdirectory. Since I'm set up (this time) with subdirs, I thought "Wow. How cool. Blogs could be accessed either way." I duplicated the code almost exactly as it was in the thread, and.... nothing. Here's how they had it:

    Options +FollowSymLinks
    RewriteEngine On
    RewriteCond %{HTTP_HOST}!^www\. [NC]
    RewriteCond %{HTTP_HOST} ^(.*)\.domain\.com [NC]
    RewriteRule (.*) http://domain.com/%1/$1 [R=301,L]

    I copied the "Options" line (just in case), and placed the last 3 lines right after "RewriteBase /" and the #uploaded files comment. (I later tried moving the "RewriteBase /" to after the rules, but that had no effect). The original thread was http://www.webmasterworld.com/forum23/2808.htm. One of the posts offered a detailed explanation of each line, which seemed to make a lot of sense while I was reading it.

    Can anyone tell me why this would not work? Did I stick it in the wrong place in the .htaccess "flow"? It seems quite similar to what DrMike posted here (except for the fact that the 'WWW' line apparently is supposed to ignore the WWW subdomain/directory):

    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^subdomain.mydomain.tld$ [OR]
    RewriteCond %{HTTP_HOST} ^www.subdomain.mydomain.tld$
    RewriteRule ^(.*)$ http://mydomain.tld/mynewuser/$1 [R=301,L]

    Issue #2:

    Whilst searching for a sitemap solution, I found this previously posted code:

    RewriteRule ^sitemap.xml /files/sitemap.xml
    RewriteRule ^robots.txt$ /files/robots.txt [L]

    Which I assumed (probably incorrectly) was "the" solution to get the sitemap pointed to the proper location. So far I've tried placing these lines right after the '#uploaded files' comment, immediately before the shipped RewriteConds, and immediately following the RewriteConds. All give me a 404 error. (I checked, and the target files do exist in files folder for that blog). Is the above incorrect for a sub-dir install? (Don't see why it would make a difference). I added xml as a valid filetype.

    I also tried this variant

    RewriteRule ^sitemap.xml /wp-content/blogs.php?file=sitemap.xml [L]

    (And, I ask again, if I see 'wp-inst/' in a post, I should just think of it as just '/' for a new install)?

    Did I miss a RewriteCond somewhere or something? Doesn't the '^' mean "anything that *begins* with 'this string'"? Should there be a '*' at the front somewhere?

    Thanks in advance to any .htaccess wizards who can help me sort this out.
    Wally

  2. WWDay3
    Member
    Posted 15 years ago #

    Noboby likes me anymore?

  3. WWDay3
    Member
    Posted 15 years ago #

    Actually, I'm going to try to answer my own question. And, introduce another.

    I attempted the following:

    RewriteRule ^sitemap.xml /wp-content/blogs.php?file=sitemap.xml [L]

    I'm not sure of the exact post it was in. All I know is the post author said it works. Said it pretty emphatically, too. However, it doesn't seem to work for me :()

    I started analyzing the line, and I came to the conclusion

    RewriteRule ^(.*/)?files/(.*) wp-content/blogs.php?file=$2 [L]

    should do the same thing. Shouldn't it? If I'm reading it right (a pretty big if at this point).

About this Topic