3

I need a set of fresh eyes on this. I'm having a tough time spotting the problem.

In folder X I have an .htaccess file with the following two lines in it:

RewriteEngine on
RewriteRule ^([A-Za-z0-9\.-]+)/?$ item-display.php?bibid=$1 [NC,L]

My interpretation is that anything in that directory will then be redirected to the item-display page. The problem is that on the item-display page, echoing out the value of bibid outputs 'display-item'. So somehow I'm redirecting from: http://localhost/test/cat/item/14056a to: http://localhost/test/cat/item/item-display.php?bibid=item-display

Any ideas?

Cheers

Cory Dee
  • 2,858
  • 6
  • 40
  • 55

3 Answers3

5

You have to exclude the file you are redirecting to as that is also matched by the pattern:

RewriteCond %{REQUEST_URI} !/item-display\.php$
RewriteRule ^([A-Za-z0-9\.-]+)/?$ item-display.php?bibid=$1 [L]
Gumbo
  • 643,351
  • 109
  • 780
  • 844
1

Try this

RewriteEngine on
RewritePath /test/cat/item
RewriteRule ^([A-Za-z0-9\.-]+)/?$ item-display.php?bibid=$1 [L]

I think the problem is that it is looking at the whole URL and not just the last item ID part.

Nick Berardi
  • 54,393
  • 15
  • 113
  • 135
  • I think you're after RewriteBase...it doesn't appear to change the results though. Gets to the right page, then thinks bibid is set to 'display-item'. I'm reading into RewriteBase further hoping to find something in the docs. – Cory Dee Apr 15 '09 at 13:53
1

The request is sub-processed so it extracts the rewritten URL's filename part I presume. Try adding the NS flag.

BYK
  • 1,359
  • 3
  • 15
  • 37