Apache Mod_rewrite规则在一台服务器上工作,但不是另一台服务器

我在httpd 2.2.15上使用mod_jk和mod_rewrite。 我有一个规则….

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

我只是想重写像/ video / videoidhere这样的/video/play.xhtml?vid=videoidhere这在我的开发机器上完美的工作,但在生产中,我得到了一个404(由Jboss生成,而不是Apache)。

这里是prod(broken)上access.log和rewrite.log的尾部。 dev(工作)上的rewrite.log完全一样,

 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" 

我可以访问http://www.fivi.com/video/play.xhtml?vid=46279d4daf5440b2844ec831413dcc3b但不是/ video / 46279d4daf5440b2844ec831413dcc3b

两台服务器甚至使用EXACT相同的httpd.conf和模块。

我build立了Apache …

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

谢谢梅森

—- 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 

这可能是一个愚蠢的,但我有时(Debian / Ubuntu的)运行到一个系统,其中ReWrite模块语句不正确的顺序,所以有一个部分:

 <IfModule mod_rewrite.so> ... </IfModule> 

在Apache看到LoadModule语句之前,这是很难通过所有的Include语句来追踪的。

如果有一个IfModule语句,请尝试将其注释掉,看看是否将您sorting。

这是旧的,但因为没有被接受的答案。 我有类似的问题,相同的重写规则,而不是开发环境。 find这个在开发环境中缺less的设置,并添加它修复它。

在mod_jk.conf中添加

JkMountCopy 'All'