Go Back   SitePoint Forums > Forum Index > Host Your Site > Apache Configuration
Newsletter FAQ Members List Calendar Mark Forums Read

New to SitePoint Forums? Register here for free!

SitePoint Sponsor
 
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Old Oct 20, 2004, 17:41   #1
agentolivia
SitePoint Enthusiast
 
agentolivia's Avatar
 
Join Date: Jul 2003
Posts: 68
.htaccess rewrite rule kills trailing slash auto redirect in parent directory

Summary of Problem: The .htaccess rewrite rule in /eventregistration/onlineteachers/ is overriding an "automatic" trailing-slash-adding redirect that is the default server behavior. This has the effect of not redirecting /eventregistration/onlineteachers to /eventregistration/onlineteachers/. A .htaccess rewrite rule in /eventregistration/ has no positive effect, but rather hair-pulling, premature-aging effect.

First, in my httpd.conf (Apache/1.3.29), I have the following (to allow .htaccess files in this directory and subdirectories the ability to use RewriteRules):

Code:
<Directory "/var/www/nwrel/eventregistration">
   AllowOverride FileInfo
            </Directory>
Second, in a /eventregistration/onlineteachers/ directory I have an .htaccess file that redirects just about everything to index.php (in order to use Harry Fuecks very cool PathVars class - PHP Anthology, Vol. 1, pg 312ff). The .htaccess looks like this:

Code:
RewriteEngine on
            RewriteRule !(\.gif|\.jp?g|\.css|\.php|^images/.*)$ index.php [nocase,last]
All is fine and dandy except for one little annoying thing: the "automatic" redirect that happens when a trailing slash is missing from a URL doesn't happen in the parent directory, "eventregistration". (I don't want a trailing slash redirect in "onlineteachers" but I do want it in "eventregistration," so that "http://www.nwrel.org/eventregistration/onlineteachers" redirects to "http://www.nwrel.org/eventregistration/onlineteachers/" and the .htaccess in "onlineteachers" kicks in)

So I tried to write a rewrite rule in the /eventregistration/ directory's .htaccess file as per the Apache docs suggestion:

Code:
RewriteEngine on
            RewriteRule ^onlineteachers$  onlineteachers/ [R]
But all I get is "Bad Request: Your browser sent a request that this server could not understand " in Firefox and a "Page Not Found" error in IE6. Oh so helpful.

I have looked everywhere, but frankly I'm new at .htaccess and mod_rewrite, so maybe I just haven't loooked for the right things. I hope someone here can help.

Thanks a ton.
Amber
agentolivia is offline   Reply With Quote
 

Bookmarks

« Previous Thread | Next Thread »

Thread Tools
Display Modes

 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Sponsored Links
 
Forum Jump


All times are GMT -7. The time now is 02:02.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Copyright 1998-2009, SitePoint Pty Ltd. All Rights Reserved