Sunday, 18 August 2013

RewriteRule not working with mod_userdir

RewriteRule not working with mod_userdir

My setup:
Ubuntu 13.04
Apache/2.2.22 (Ubuntu)
PHP 5.4.9-4ubuntu2.2
--
$ ls /etc/apache2/mods-enabled/*.load
alias.load auth_basic.load authn_file.load authz_default.load
authz_groupfile.load authz_host.load authz_user.load autoindex.load
cgi.load deflate.load dir.load env.load expires.load
mime.load
negotiation.load php5.load reqtimeout.load rewrite.load
setenvif.load status.load userdir.load
Using mod_userdir, which redirects to /home/*/www
I have an .htaccess file in /home/*/www/styles with the following directives:
RewriteEngine On
RewriteRule (styles-files/.+)\.(\d{10})\.(\w{2,4})$ $1.$3 [L]
Now here's the confusing part (personal details masked out)
Loading http://localhost/~***/styles/styles-files/css/jquery.qtip.css
works correctly (the file is displayed in the browser)
Loading
http://localhost/~***/styles/styles-files/css/jquery.qtip.1376640525.css
gives me 404 error, but the message says
"/home/*/www/styles/styles-files/css/jquery.qtip.css" not found, so it
looks to be redirecting. And that is the correct path to the file.
Rewrite log shows:
(3) [perdir /home/***/www/styles/] strip per-dir prefix:
/home/***/www/styles/styles-files/css/jquery.qtip.1376640525.css ->
styles-files/css/jquery.qtip.1376640525.css
(3) [perdir /home/***/www/styles/] applying pattern
'(styles-files/.+)\\.(\\d{10})\\.(\\w{2,4})$' to uri
'styles-files/css/jquery.qtip.1376640525.css'
(2) [perdir /home/***/www/styles/] rewrite
'styles-files/css/jquery.qtip.1376640525.css' ->
'styles-files/css/jquery.qtip.css'
(3) [perdir /home/***/www/styles/] add per-dir prefix:
styles-files/css/jquery.qtip.css ->
/home/***/www/styles/styles-files/css/jquery.qtip.css
(1) [perdir /home/***/www/styles/] internal redirect with
/home/***/www/styles/styles-files/css/jquery.qtip.css [INTERNAL REDIRECT]
but then right after that, Apache throws an error saying
[error] [client 127.0.0.1] File does not exist: /var/www/home
The rewrite works correctly if I move everything to /var/www. There seems
to be some sort of a clash between mod_rewrite and mod_userdir, but I
can't find anything about it online.
Any thoughts on what might be happening here and how I can fix this?

No comments:

Post a Comment