Reputation: 611
I need to redirect edit/profil
to edit.php?p=profil
, but the p
parameter is not send to edit.php
. Do you know what could be the reason for that?
The server is a shared server, so I don't have access to the Apache config files.
My folder is located in /fr/intranet
and contains two files : edit.php
and .htaccess
.
The content of edit.php
is very simple :
<?php
echo '<pre>';
echo "This is edit.php\n";
var_dump($_GET);
echo '</pre>';
?>
And the content of .htaccess
is the following:
Options +FollowSymlinks
RewriteEngine on
RewriteBase /fr/intranet/
RewriteRule ^edit/profil/?$ edit.php?p=profil [L]
RewriteRule ^test/profil/?$ edit.php?p=profil [L]
When I load /fr/intranet/test/profil
, the PHP script displays :
This is edit.php
array(1) {
["p"]=>
string(6) "profil"
}
When I load /fr/intranet/edit/profil
(this is the reason I post here), the PHP script displays :
This is edit.php
array(0) {
}
There is a Wordpress installed in the /fr/ folder with a .htaccess. I wondered if it could have some rewriting rules in conflict with mine. It should not, as my htaccess have the priority. Besides there are no rules that may produce the behavior I encounter:
RewriteEngine On
RewriteBase /fr/
RewriteRule ^index\.php$ - [L]
# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]
I know about the QSA flag, but it's not the problem here. If I have understood correctly, the QSA flag looks for the entire URL (including GET parameters) when redirecting, but I don't have GET parameters in the requested URL. Adding it doesn't change the behavior anyway.
If I create a file named /fr/intranet/test.php
with the following content:
<?php
echo '<pre>';
echo "This is test.php\n"
var_dump($_GET);
echo '</pre>';
?>
and if I load /fr/intranet/test/profil
, then I get the following output:
This is test.php
array(0) {
}
Also, if I remove the .htaccess
file, loading /fr/intranet/test
displays the output of /fr/intranet/test.php
.
Everything behave like there were an hidden rules more or less like this one:
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^([^/]+).*$ $1.php [L]
I have found here that switching RewriteEngine off then on in the .htaccess
file may disable parent rewriting rules. But it didn't solve my problem.
Upvotes: 0
Views: 984
Reputation: 96325
Try disabling MultiViews (Options -MultiViews
), it is often the one to blame in such situations.
(For a more detailed explanation of what MultiViews does, see http://httpd.apache.org/docs/2.2/en/mod/mod_negotiation.html#multiviews. This often interferes with rewriting when a file with the same name [minus extension] exists as the “fake” path segment one tries to rewrite.)
Upvotes: 3