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 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
share|improve this question
    
From the above, I guess the error is not due to the rewrite rules you showed, but more in the config you use to connect Apache to JBoss. Please add those parts to the question as well. –  earl Jul 22 '10 at 14:30
    
I agree, looks like mod_rewrite is working just fine, but something under it (probably JBoss) is returning the 404. –  Chris S Jul 22 '10 at 14:37
    
thanks guys. I attached what I think are the relevant bits of the jk, httpd, etc conf files. I think this has Something to do with the virtual hosts. All config files are the same on the working and not working server, but on dev I have to comment out the "ServerName *" virtual host so it won't redirect me to www.fivi.com –  Mason Jul 22 '10 at 17:20
    
I can't comment, so I'll post here. Are you using the rewrite rule in .htaccess? This is the most common error about mod_rewrite. You need to AllowOverride FileInfo in a <Directory> block pointing to the directory where you have the rules. If not, put those rules in httpd.conf. If you keep making changes to those then you'll have to restart apache if the rules are in httpd.conf. –  nileshgr Aug 10 '10 at 13:29
    
Thanks for the answer Nilesh. However I do have these rules only in httpd.conf. I'm not using .htaccess files at all. –  Mason Aug 11 '10 at 21:48

1 Answer 1

This might be a stupid one, but I've occasionally (Debian/Ubuntu) run into a system where the ReWrite module statements weren't in the proper order, so there was a section:

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

which came (this was tough to trace down via all the Include statements) before apache saw the LoadModule statements.

If there's an IfModule statement, try commenting it out and see if that sorts you out.

share|improve this answer

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.