Preventing broken links

Topics: Developer Forum, User Forum
Aug 25, 2011 at 10:23 PM
Edited Aug 26, 2011 at 12:42 AM

Hi Cheeso

I'm soooo close to getting this working but stuck on the last bit so have to ask for help I'm afraid.

I've got this:

RewriteEngine on
StatusInquiry ON
RewriteLogLevel 5
RewriteLog c:\inetpub\wwwroot\domain\htdocs\IIRF\iirf
RewriteMap mapfile txt:c:\inetpub\wwwroot\domain\htdocs\IIRF\mapfile.txt
RewriteRule  ^/dets/(.*) /detail.asp?id=${mapfile:$1} [L]

where mapfile contains:
abcdef     123

the aim being that requests to get routed to

The redirect itself is working and gets the right page but very slow - I assume due to the log level or a symptom of my problem which is all the page content - stylesheets & other links are all prefixed with det/

I've trawled through the manual and this board but I'm stumped. All my links in the detail.asp program are relative.

I can get around it by changing all my links or moving detail.asp into the dets folder ..... but I'm sure there is a smarter method!

Thanks in advance, great product.




Aug 26, 2011 at 11:41 AM

Hi - just an update on this I've got a work around to avoid getting too much of a migraine with regex! I thought I'd share it with others if it's any use...however still one issue to resolve if anyone can help....(see bottom)

I did want to do something like where it would rewrite to using a mapfile.

The trouble I had was the rewrite rule/s worked ok doing the rewrite of the main URL but the in page links and images were all broken. I tried all sort of weird and wonderful regex expressions from the help but ultimately now use this:

instead of having I now just use

I then have my mapfile as normal:   product1 1234

and the rewrite rule:   RewriteRule ^/([^/\.]*)$ /detail.asp?id=${mapfile:$1} [L]

The rule I think is saying rewrite any URL where there is no / in it and no . in it
so will match and rewrite to /details.asp?id=1234

will not match - great!

Because the non matches will not be rewritten and the relative location of the actual page is the root of the website, the internal links/images/css are left unchanged- which was the original problem.

However -
If there is a request for the url where registration is NOT in the mapfile (but registration is a valid URL in it's own right normally) then this will match the rule and rewrite as /details.asp?id=0 whereas I need it to not rewrite. Is there are method to tell IIRF to ignore rewriting unmatch mapfile entries?

Aug 26, 2011 at 7:52 PM

>  Is there are method to tell IIRF to ignore rewriting unmatch mapfile entries?

yes - you can use a RewriteCond for that.

There's a section in the doc covering this.

Aug 29, 2011 at 9:12 PM

Thanks Cheeso - and sorry!

I think I got 'manual blindess' trying to read and understand the whole thing in one day was maybe a bit much to do!

Aug 31, 2011 at 2:40 AM

No prob, glad to help.

All the syntax for directives and rules - It's a lot to absorb all at once.