NYCPHP Meetup

NYPHP.org

[nycphp-talk] OT - mod_rewrite Assistance

Rob Marscher rmarscher at beaffinitive.com
Thu Apr 12 18:27:50 EDT 2007


> On Apr 11, 2007, at 1:51 PM, Joseph Crawford wrote:
> The rule is running properly but never stopping until the browser
> stops it. if you go to http://dev.sub.domain.com/ it will redirect you
> to http://dev.sub.domain.com/sub/ but it goes continuosly adding more
> and more /sub/ to the url.I've hit that problem before... If I  
> remember right, I think it's because when it goes into http:// 
> dev.sub.domain.com/sub/ it process the same set of rewrite rules  
> and they still match so it goes and rewrites it again to http:// 
> dev.sub.domain.com/sub/sub/

Off the top of my head, I think one simple way to solve it is to put  
a .htaccess file in each of your "subdirectory" folders that simply  
has RewriteEngine On which clears out the rules for that folder so it  
won't try to process the rules of the parent folder.

Either that or you figure out how to put a conditional so that it  
doesn't match the second time around.

> Also i do not wish to show the url in the address bar. All i want to
> show there is http://dev.sub.domain.com/ but in the background that
> should rewrite to http://dev.sub.domain.com/sub/
> So if i type in http://dev.sub.domain.com/folder/ in the background it
> will actually be calling http://dev.sub.domain.com/sub/folder/

The http://%{HTTP_HOST}/ part of your last rule is causing that.

I'm actually having a bit of trouble deciphering how your rule works  
exactly.  There might be a simpler way to do it.  I guess I could  
RTFM... but if you've got a second to explain in english, what does % 
{ENV:REDIRECT_STATUS} and %3%{REQUEST_URI} do?

-Rob





More information about the talk mailing list