basic category url rewrite

Sep 27, 2009 at 3:45 AM

Hi there,

I'm trying to get a basic category rewrite url work,

my rewrite rule is this

# category redirects
RewriteRule ^/([^/]+)/ /Browse.aspx?Category.aspx=$1

That seems to work well, I want to redirect something like

http://www.domain.com/SomeCategory
to

http://www.domain.com/Browse.aspx?Category.aspx=SomeCategory

I had to add a trailing slash redirect for it to be actually rewritten though (anyway around this, or not cause a response to be sent to the client only for the client to make another request)

# add a trailing slash
RewriteRule ^([^.?]+[^.?/])$ $1/ [R=301,L]

But I'm having a problem, all my css is getting screwed up, when I navigate too

http://www.domain.com/SomeCategory

instead of the css coming from "http://www.domain.com/App_Themes/..." it is coming "http://www.domain.com/SomeCategory/App_Themes/...."

what is the best way to fix this?

i've tried

RewriteCond %{REQUEST_URI} ^*/*/
RewriteRule (.*)App_Themes/(.*) /App_Themes/$2 [R, NC]

But I seem to get stuck in a redirect loop, firebug show my css just constantly loading with a 302.  So i think i need to make a redirect if /App_Themes/ is only in a subdirectory and not directly off www.domain.com (and I dont want to use www.domain.com in the rules, since im running this on localhost atm)

I basically want to setup these rules

1. If Page exists, just return it

2. domain.com/Search/SearchText = redirect (masking redirect url) to domain.com/Search.aspx?text=SearchText

3. domain.com/Digits = redirect (masking redirect url) to domain.com/id.aspx?id=Digits (eg "http://www.domain.com/1234")

4. domain.com/AnythingElse = redirect (masking redirect url) to domain.com/Browse.aspx?Category=AnythingElse

Also do the rules continue processing one after another, or do they stop when a match is found.  if they continue, is there a way to make them stop?

TIA