Help with mod_rewrite re-map

Discussion in 'Web Design and Development' started by Makosuke, Mar 13, 2007.

  1. Makosuke macrumors 603

    Joined:
    Aug 15, 2001
    Location:
    The Cool Part of CA, USA
    #1
    I've got what seems to be a trivial thing to do but I can't seem to get it working right. What I want to do is transparently remap "index.html" (only) to "index.shtml" without actually visibly redirecting. After a bit of poking around, it seemed as if this .htaccess command should do the trick:

    ...but while it DOES seem to do what I want it to on one domain, on another I keep getting visibly forwarded to index.shtml. Am I missing something here?


    If you're curious, I want to do this because my host (DH) only runs files with an .shtml extension through the SSI parser by default. I have largely static pages, so this is good--no extra time parsing what doesn't need it. But now I'm trying to add a little SSI directive to the main index page for the entire domain. Up to now, I'd been using index.html for that, and I don't want to affect the links to such. But if I do a standard "Redirect 301" statement, when somebody hits the domain without anything after the first / it tacks on index.shtml instead of leaving it "bare". I prefer the "bare" style, and I also don't really want to be visibly redirecting to .shtml, either.

    The funny thing is when I added the above to the .htaccess on a test domain, it worked absolutely perfectly. When I did it on my main domain, no go.

    If there were a way to use an AddHandler directive in .htaccess to run only one specific filename through the SSI parser rather than ALL .html files, that would do the trick too, of course, but I don't see that that's an option, either.
     
  2. Makosuke thread starter macrumors 603

    Joined:
    Aug 15, 2001
    Location:
    The Cool Part of CA, USA
    #2
    Ok, I'm a complete raging idiot. The reason it wasn't doing what I thought it should was I had left a Redirect directive above it in the .htaccess file, so it was getting redirected before it was getting rewritten.

    I'm still a bit stuck, though, since that directive remaps EVERY index.html rather than just the root one. I thought the RewriteBase setting would fix that, but I was obviously wrong.

    [Edit: Ok, think I got it; I needed a ^ before the index.html; I had it in there originally but had removed it in the process of confused testing.]
     

Share This Page