When accessing a *.php lead to Autostart.php? url=*. php

Asked

Viewed 87 times

0

Hello,

I have a problem, I need you to access any file .php, he directs to autostart.php?url=*.php

Explanation:

In the autostart.php it da include in a file and after it gives include in the page that is on GET.

I did it with HTACCESS, but I couldn’t make it work as I wanted.

<IfModule mod_rewrite.c>
    RewriteEngine on

    RewriteRule .*\.(php)$ autostart.php?url=$1 [R,NC,L]
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d
</IfModule>
  • 1

    It doesn’t pay to use "autoinclude" from PHP itself then? If you have access to this setting, you can use auto_prepend_file e auto_append_file.

  • More like, I would have to edit php.ini, I need a solution in the source code itself, since I need to use several times.

  • Actually, it wouldn’t be ^(*.)\.php)$ autostart.php?url=$1? Because $1 would take the regex group returned in the first expression (and in your case this group would always be "php"). I hope I didn’t bullshit you, rsrsrsrs

1 answer

0


Solution:

RewriteEngine on

RewriteRule (.*\.php)$ autostart.php?url=$1 [R,NC,L]
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d

I don’t think it’s a good idea to use this method to include files. If the option allow_url_include php is enabled you have just opened a giant gap in your system that will allow anyone to enter and run a php script on your server.

If you’re really gonna do it that way do not give include in the parameter url directly without first doing a validation to see if the file can actually be included in your script.;

  • Thanks for solving my problem, Autostart it validates with is_file(). Thanks for the tips.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.