0

I've been struggling to get the following rewrite working

^/agatedepot/([0-9.]+)/([0-9a-zA-Z._]+)\?doc-id=([0-9a-zA-Z._\-]+)

to

/agateDepot.php?date=$1&filename=$2&doc-id=$3

I know that mod_rewrite is working. I know that it is reading the .htaccess file, I'm just not seeing any redirecting happening. Here's what I have in my .htaccess file

RewriteEngine On
RewriteRule ^/agatedepot/([0-9.]+)/([0-9a-zA-Z._]+)\?doc-id=([0-9a-zA-Z._\-]+) /agateDepot.php?date=$1&filename=$2&doc-id=$3

Any help would be greatly appreciated. I imagine it is something simple, but I have not been able to figure it out. No errors in the Apache error log, and the access log is simply recording a 404.

2 Answers 2

1

It appears that you are attempting to match the query string in the 'pattern'. This is not the correct way of doing that.

Try this instead:

RewriteEngine On
RewriteCond %{QUERY_STRING} ^doc-id=([0-9a-zA-Z._\-]+)$
RewriteRule ^/agatedepot/([0-9.]+)/([0-9a-zA-Z._]+) /agateDepot.php?date=$1&filename=$2&doc-id=%1?
0

I think you have to escape the dot when it is present inside the range brackets. Otherwise it matches "anything". If that's the case, Your first capture group will gobble all available characters and the other capture groups won't get anything.

like this

^/agatedepot/([0-9\.]+)/([0-9a-zA-Z\._]+)\?doc-id=([0-9a-zA-Z\._\-]+) 

You must log in to answer this question.