Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've been struggling to get the following rewrite working




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

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

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

share|improve this answer

Your Answer


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