0

I'm trying to use RewriteMap in my virtualhost, but not getting any luck.

Here is the content of my virtualhost file, with an entry (line) starting with RewriteMap. From what I read, the file /etc/fixit.php should be executed. But I tested to put a simple line file_put_contents('/etc/test.txt','abcd', FILE_APPEND); and the test.txt file is not created.

    <VirtualHost *:80>
    SuexecUserGroup "#1004" "#1004"
    ServerName test2.domain.com
    ServerAlias www.test2.domain.com
    DocumentRoot /home/test2/public_html
    ErrorLog /var/log/virtualmin/test2.domain.com_error_log
    ErrorDocument 403 "This is the default page for new website."
    CustomLog /var/log/virtualmin/test2.domain.com_access_log combined
    ScriptAlias /cgi-bin/ /home/test2/cgi-bin/
    ScriptAlias /awstats/ /home/test2/cgi-bin/
    DirectoryIndex index.html index.htm index.php index.php4 index.php5
    RewriteMap fixurl prg:/etc/fixit.php
    <Directory /home/test2/public_html>
    Options -Indexes +IncludesNOEXEC +SymLinksIfOwnerMatch +ExecCGI
    allow from all
    AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
    Require all granted
    AddType application/x-httpd-php .php
    AddHandler fcgid-script .php
    AddHandler fcgid-script .php7.0
    FCGIWrapper /home/test2/fcgi-bin/php7.0.fcgi .php
    FCGIWrapper /home/test2/fcgi-bin/php7.0.fcgi .php7.0
    </Directory>
    <Directory /home/test2/cgi-bin>
    allow from all
    AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
    Require all granted
    </Directory>
    RemoveHandler .php
    RemoveHandler .php7.0
    php_admin_value engine Off
    FcgidMaxRequestLen 1073741824
    <Files awstats.pl>
    AuthName "test2.domain.com statistics"
    AuthType Basic
    AuthUserFile /home/test2/.awstats-htpasswd
    require valid-user
    </Files>
    php_value memory_limit 32M
    IPCCommTimeout 41
    </VirtualHost>

Here is the content of my test /etc/fixit.php file

<?php
file_put_contents('/etc/test.txt','abcd', FILE_APPEND);
?>

I understand that this is not a complete RewriteMap example, since I haven't added a rewrite rule to the file. But at least the fixit.php file should be executed, is it correct?

Thanks for any help.

aye
  • 229
  • 3
  • 11

1 Answers1

0

Try making your fixit.php write to /tmp/test.txt instead; unless your UID 1004 has write access to /etc (it may, but it probably shouldn't), fixit.php may well be running, but not able to create the file.

Craig Miskell
  • 4,086
  • 1
  • 15
  • 16
  • It still doesn't write to /tmp. I tried to echo something from fixit.php, but it also doesn't display in the browser. Everything in browser works just like there is no rewritemap line. I'm using ubuntu 16.04, and installed virtualmin, not sure if it affects the behaviour. – aye Jul 29 '17 at 08:04