1

I have a redirection but I don't know where it is activated?

I have installed a PHP application called GARRADIN. There is an .htaccess containing this line:

RewriteRule admin/plugin/(.*?)/(.*) /admin/plugin.php?_p=$1&_u=$2 [QSA,L]

This redirection works. plugin.php is called but parameters $1 and $2 are empty. $_GET['_p'] returns nothing into the script.

To understand why parameters are not transmitted, I have tried to modify .htaccess but whatever I do, it is not taken into account. It seems that this redirection is configured somewhere else?

What I did: - I have inserted an error into .htaccess, and I obtain a server error => OK, .htaccess is taken into account. - I modified the line to redirect to XXXXplugin.php but plugin.php is still called. - renamed .htaccess to BAK.htaccess => redirection is still working! - I have reset the browser cache, used another browser => same redirection.

so WHERE the redirection is configured?

THX for you help.

Complete .htaccess:

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteRule admin/plugin/(.*?)/(.*) /admin/XXXXXXXXXXXXplugin.php?_p=$1&_u=$2 [QSA,L]
    RewriteRule f/([\d\w]+)/(.*) /file.php?id=$1&file=$2 [QSA,L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule .* /index.php [QSA,L]
</IfModule>

<IfModule !mod_rewrite.c>
    ErrorDocument 404 /index.php
</IfModule>
2
  • Is there a .htaccess in the admin directory or do you have any rules in the Server config files?
    – eckes
    Dec 17, 2018 at 4:31
  • YES there is an .htaccess also in www/admin but it only contains: ErrorDocument 404 "<h1>Erreur 404</h1><h2>Page non trouv&eacute;e</h2><p><a href=../>Retour</a></p>" Dec 17, 2018 at 11:15

2 Answers 2

2

@MrWhite took me to the right direction. I had to deactivate MultiViews, not at the top of the .htaccess (which leads to a server error) but into the virtual host configuration file, and into a section.

<Directory /home/gestion_o2form/public_html/www>
    Options -Indexes +IncludesNOEXEC +FollowSymLinks -MultiViews <= HERE
    allow from all
    AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,-MultiViews,SymLinksIfOwnerMatch
    Require all granted
    AddType application/x-httpd-php .php
</Directory>

And IT WORK!

THANKS to all especially @MrWhite

1
  • It didn't work in .htaccess because you have an erroneous - in the AllowOverride directive. It should be ...,Indexes,MultiViews,SymLinksIf... (no hyphen before MultiViews here). (It looks like you had tried to disable MultiViews, but in the wrong place?) However, since you have access to the vHost config, it's preferable to disable this here anyway. Thanks for the feedback, glad you got it sorted.
    – MrWhite
    Dec 17, 2018 at 12:59
1

The behaviour you are seeing is indicative of having MultiViews (part of mod_negotiation) enabled in your server config (it is not enabled by default).

Since /admin is a physical directory and plugin corresponds to a file basename in that directory, mod_negotiation searches for a suitable response by testing various file extensions. In this case it will issue an internal subrequest for /admin/plugin.php - without any query parameters. This happens before mod_rewrite, hence why your updated directive does not appear to do anything.

You need to disable MultiViews.

At the top of your .htaccess file add the following:

Options -MultiViews

This redirection works.

This is more commonly called an internal rewrite. A "redirect" implies an external redirect.

Note that the regex admin/plugin/(.*?)/(.*) potentially matches more than is probably intended, as you are missing a start-of-string anchor (^). So it would also match something like /foobaradmin/plugin//.

4
  • I had a Multiviews option activated into the virtual host conf file. Following your suggestion, I have deactivate it: AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,-MultiViews,SymLinksIfOwnerMatch Dec 17, 2018 at 11:18
  • I have put -MultiViews I'am not sure it works? anyway this does not work. Dec 17, 2018 at 11:27
  • the I have put Options -MultiViews at the top of .htaccess. It goes to an internal server error. Dec 17, 2018 at 11:29
  • Ah yes, that's the wrong place. The AllowOverride directive tells Apache what directives can be overridden in .htaccess. Changing MultiViews to -MultiViews here is not valid (the same as if you'd removed MultiViews altogether) and essentially means that MultiViews cannot be overridden in .htaccess - hence the 500 error when trying to do so. You need to use the Options directive (in .htaccess or server config), as you have done.
    – MrWhite
    Dec 17, 2018 at 13:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .