Redirect works
Alias /www /var/www
<Directory /var/www>
Options +FollowSymLinks
DirectoryIndex index.php
<IfModule mod_rewrite.c>
RedirectMatch /www/php/(.*) http://www.google.com/usingredirection/$1
</IfModule>
=> http://myserver/www/php/foo redirect to http://www.google.com/usingredirection/foo
So : Mod_rewrite is loaded (because of IfModule) and mod_alias too
But RewriteRule doesn't work
<Directory /var/www>
Options +FollowSymLinks
DirectoryIndex index.php
<IfModule mod_rewrite.c>
RewriteEngine on
Rewritebase /var/www
RewriteRule ^/www/php/(.*)$ http://www.google.com/rule1/$1 [R,L]
RewriteRule ^(.*)$ http://www.google.com/rule2/$1 [R,L]
</IfModule>
apache log says /var/www/php/foo doesn't exist (which is true) but why doesn't it apply rewriterule ?
All of this is in a *.conf file. I tried to move rewrite rule in an htacess but as soon as I add a rewriteengine on it always complain Options FollowSymLinks or SymLinksIfOwnerMatch is off which implies that RewriteRule directive is forbidden even if FollowSymLinks was on
So right now I only try to mimic the redirect using rewriterule
My ultimate goal
/www/php/*.php serve php (and existing file) as usual
/www/php/preview/* => /www/php/preview.php?path=$1
/www/php/* => /www/php/index.php?path=$1
Edit : After the first comments, I feel like posting the whole stuff could help
So here is the httpd.conf. This file is not by me. It's the standard conf of a readyNAS Duo. I just added an include at the very end to my own conf.
httpd.conf
ServerRoot /frontview/ui/resource/html
...
Listen 80
# Please keep this LoadModule: line here, it is needed for installation.
LoadModule perl_module /usr/lib/apache2/modules/mod_perl.so
LoadModule auth_pam_module /usr/lib/apache2/modules/mod_auth_pam.so
LoadModule auth_sys_group_module /usr/lib/apache2/modules/mod_auth_sys_group.so
LoadModule apreq_module /usr/lib/apache2/modules/mod_apreq2.so
APREQ2_ReadLimit 2147483648
LoadModule php5_module /usr/lib/apache2/modules/libphp5.so
AddType application/x-httpd-php .php
PHPIniDir /etc/php5/apache2
ExtendedStatus On
User admin
Group admin
ServerAdmin admin@localhost
Options All Indexes
DocumentRoot /frontview/ui/resource/html
<Files ~ "^\.ht">
Order allow,deny
Deny from all
</Files>
<Files ~ "\.(js|jpg|jpeg|gif|html|htm|png|css)">
Header set Pragma: public
</Files>
UseCanonicalName Off
TypesConfig /etc/mime.types
DefaultType text/plain
<IfModule mod_mime_magic.c>
MIMEMagicFile share/magic
</IfModule>
HostnameLookups Off
...
<IfModule mod_autoindex.c>
IndexOptions Charset=
IndexOptions FancyIndexing NameWidth=*
AddIconByEncoding (CMP,/images/Icons/compressed.gif) x-compress x-gzip
...more icons...
AddIcon /images/Pix.gif ^^BLANKICON^^
DefaultIcon /images/Icons/unknown.gif
ReadmeName /html/AUTOINDEX.html
HeaderName HEADER.html
IndexIgnore .??* *~ *# HEADER* README* RCS CVS *,v *,t
</IfModule>
<IfModule mod_mime.c>
AddEncoding x-compress Z
...more mime...
AddType video/x-ms-wvx .wvx
AddHandler cgi-script .cgi .sh .pl
</IfModule>
#AddDefaultCharset utf-8
<IfModule mod_setenvif.c>
BrowserMatch "Mozilla/2" nokeepalive
...more browser...
# Drop the Range header when more than 5 ranges.
# CVE-2011-3192
SetEnvIf Range (,.*?){5,} bad-range=1
RequestHeader unset Range env=bad-range
</IfModule>
DAVLockDB /ramfs/WebDAVLock.db
DAVMinTimeout 600
Listen 443
SSLEngine On
SSL stuff ...
# -------------------------------------------------------------------
# Uncomment following when more graceful error message docs are used.
# Currently IE defaults it it's browser message, overriding any error
# docs we create anyway.
# -------------------------------------------------------------------
# ErrorDocument 401 /error/401.html
# ErrorDocument 403 /error/403.html
# ErrorDocument 404 /error/404.html
# ErrorDocument 500 /error/500.html
# Alias /error /frontview/ui/error
<Location />
Options ExecCGI
DirectoryIndex redirect.html index.html index.htm index.php
</Location>
...
<Location /index.html>
SetHandler server-status
Order Deny,Allow
Deny from all
</Location>
Alias /images/ /frontview/ui/resource/images/
...
PerlSwitches -I /etc/frontview/addons/ui
Alias /addons/ /etc/frontview/addons/ui/
Alias /admin /frontview/ui/resource/html
<Location /admin>
DirectoryIndex index.html
Options ExecCGI
AuthType Basic
AuthName "Control Panel"
require user admin
</Location>
Alias get_handler /frontview/lib
PerlSwitches -I /frontview/lib
PerlModule Frontview
PerlModule get_handler
<Location /get_handler>
SetHandler perl-script
PerlHandler get_handler
PerlSendHeader On
Options ExecCGI
Order allow,deny
Allow from all
AuthType Basic
AuthName "Control Panel"
require user admin
</Location>
Alias /np_handler /frontview/lib
<Location /np_handler>
Options ExecCGI
DirectoryIndex np_handler.pl
Allow from all
</Location>
LoadModule listhandler_module /frontview/lib/mod_listhandler.so
<Location /list_handler>
SetHandler listhandler
</Location>
Alias /dir_list /frontview/lib/dir_list.pl
<Location /dir_list>
AuthType Basic
AuthName "Control Panel"
require user admin
Options ExecCGI
Allow from all
</Location>
...
the file ends with Include /etc/frontview/apache/Virtual.conf
which is
<VirtualHost _default_:80>
SSLEngine off
RewriteEngine on
RewriteRule ^/admin$ https://%{SERVER_NAME}/admin
RewriteRule ^/admin/(.*)$ https://%{SERVER_NAME}/admin/$1 [R,L]
</VirtualHost>
then httpd.conf ends with an include of my file
Alias /www /var/www
<Directory /var/www>
Options +FollowSymLinks
DirectoryIndex index.php
#redirecting works
#RedirectMatch /www/php/(.*) http://www.google.com/redirecting/$1
RewriteEngine on
#rewriterule dont work
RewriteRule ^(.*)$ http://www.google.com/rewriting/$1 [R,L]
</Directory>
I removed Rewritebase which is supposed to be unnecessary. I removed 1 rule to make things more clear. Right now I expected this to catch all server/www/php/* and redirects them to Google but it still doesn't work