BenjaVR BenjaVR - 2 months ago 8
PHP Question

WAMP automatically adds .php extension to file with RewriteRule

I am trying to rewrite my url with apache .htaccess (rewriting) as following:

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l

RewriteRule ^(.+)/?$ index.php?url=$1 [QSA,L]


My small project structure is:


  • .htaccess

  • index.php

  • test.php



Everything works fine, whatever I type after the "/" is in my $_GET["url"] variable. But as soon as I type in domain.com/index, it somehow automatically adds the .php extension to my url and leaves my $_GET["url"] empty. Same story when I try domain.com/test: it goes to test.php instead of rewriting to domain.com/url=test.

The strangest thing is that on 000webhost.com it all works perfectly! When I upload the same file(s), its shows up the index and test in my $_GET["url"] variable.

Hope someone can help me!

Gratz

Answer

It was because the Multiviews option was enabled. Removing this one fixed the problem.