Apache Mod_rewrite rule working on one server, but not another

Posted by Mason on Server Fault See other posts from Server Fault or by Mason
Published on 2010-07-19T23:24:41Z Indexed on 2012/04/16 5:33 UTC
Read the original article Hit count: 448

Filed under:
|
|

I am using mod_jk and mod_rewrite on httpd 2.2.15. I have a rule....

RewriteCond %{REQUEST_URI} !^/video/play\.xhtml.*
RewriteRule ^/video/(.*) /video/play.xhtml?vid=$1 [PT]

I just want to rewrite something like /video/videoidhere to /video/play.xhtml?vid=videoidhere This works perfectly on my developer machine, but on production I get a 404 (generated by Jboss, not Apache).

here is the tail of access.log and rewrite.log on prod (broken). the rewrite.log is exactly the same on dev(working)

applying pattern '^/video/(.*)' to uri '/video/46279d4daf5440b2844ec831413dcc3b'
RewriteCond: input='/video/46279d4daf5440b2844ec831413dcc3b' pattern='!^/video/play\.xhtml.*' => matched
rewrite '/video/46279d4daf5440b2844ec831413dcc3b' -> '/video/play.xhtml?vid=46279d4daf5440b2844ec831413dcc3b'
split uri=/video/play.xhtml?vid=46279d4daf5440b2844ec831413dcc3b -> uri=/video/play.xhtml, args=vid=46279d4daf5440b2844ec831413dcc3b
forcing '/video/play.xhtml' to get passed through to next API URI-to-filename handler
"GET /video/46279d4daf5440b2844ec831413dcc3b HTTP/1.1" 404 420 "-" "Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.6) Gecko/20100628 Ubuntu/10.04 (lucid) Firefox/3.6.6"

I can access http://www.fivi.com/video/play.xhtml?vid=46279d4daf5440b2844ec831413dcc3b but not /video/46279d4daf5440b2844ec831413dcc3b

Both server are even using the EXACT same httpd.conf, and modules.

I built Apache with...

./configure --prefix /usr/local/apache2.2.15 --enable-alias --enable-rewrite --enable-cache --enable-disk_cache --enable-mem_cache --enable-ssl --enable-deflate

Thanks, Mason

----UPDATE---- -mod-jk.conf

JkWorkersFile /usr/local/apache2.2.15/conf/workers.properties
JkLogFile /var/log/mod_jk.log
JkLogLevel info
JkLogStampFormat "[%a %b %d %H:%M:%S %Y]"
JkOptions +ForwardKeySize +ForwardURICompatUnparsed -ForwardDirectories
JkRequestLogFormat "%w %V %T"
JkShmFile run/jk.shm
<Location /jkstatus>
JkMount status
Order deny,allow
Deny from all
Allow from 127.0.0.1
</Location>

-workers.properties

worker.node1.port=8009
worker.node1.host=75.102.10.74
worker.node1.type=ajp13
worker.node1.lbfactor=20
worker.node1.ping_mode=A #As of mod_jk 1.2.27
worker.node2.port=8009
worker.node2.host=75.102.10.75
worker.node2.type=ajp13
worker.node2.lbfactor=10
worker.node2.ping_mode=A #As of mod_jk 1.2.27
worker.loadbalancer.type=lb
worker.loadbalancer.balance_workers=node2,node1
worker.loadbalancer.sticky_session=True
worker.status.type=status

-httpd.conf

ServerName www.fivi.com:80
Include /usr/local/apache2.2.15/conf/mod-jk.conf
NameVirtualHost *
<VirtualHost *>
  ServerName *
  DocumentRoot /usr/local/apache2/htdocs
  JkUnMount /* loadbalancer
  RedirectMatch 301 /(.*) http://www.fivi.com/$1
</VirtualHost>

<VirtualHost *>
  ServerName www.fivi.com
  ServerAlias www.fivi.com images.fivi.com 
  JkMount /* loadbalancer
  JkMount / loadbalancer

[root@fivi conf]# /usr/local/apache2.2.15/bin/httpd -M

Loaded Modules:
 core_module (static)
 authn_file_module (static)
 authn_default_module (static)
 authz_host_module (static)
 authz_groupfile_module (static)
 authz_user_module (static)
 authz_default_module (static)
 auth_basic_module (static)
 cache_module (static)
 disk_cache_module (static)
 mem_cache_module (static)
 include_module (static)
 filter_module (static)
 deflate_module (static)
 log_config_module (static)
 env_module (static)
 headers_module (static)
 setenvif_module (static)
 version_module (static)
 ssl_module (static)
 mpm_prefork_module (static)
 http_module (static)
 mime_module (static)
 status_module (static)
 autoindex_module (static)
 asis_module (static)
 cgi_module (static)
 negotiation_module (static)
 dir_module (static)
 actions_module (static)
 userdir_module (static)
 alias_module (static)
 rewrite_module (static)
 so_module (static)
 jk_module (shared)
Syntax OK

© Server Fault or respective owner

Related posts about apache2

Related posts about mod-rewrite