Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question
add comment

2 Answers

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?
share|improve this answer
add comment

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\._\-]+) 
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.