1

I have a problem with my local WAMP server on Windows, it automatically adds the extension ".php" to the url if the file exists. For example, in the following structure:

+ www
  + files
    - main.php

if I call the url http://localhost/files/main it automatically shows me the file main.php.

I was trying to identify where the redirection is but I have not found it. I clarify that I do not have any ".htaccess" file, I have even tried disabling the extension mod_rewrite, I have also searched for a VirtualHost that is redirecting and I have not found anything either.

Removing the Type application / x-httpd-php .php no longer redirects, but of course, it no longer interprets the PHP files.

I need to solve this since it is giving me problems when wanting to rewrite a url with "htaccess" since it adds the extension ".php" to the file.

For example, with the following .htaccess file:

RewriteEngine On
RewriteRule (.*) files/main.php?url=$1 [QSA,L]

And the following main.php file:

<?php print_r($_GET); ?>

When calling the url http://localhost/files/main/param the file main.php runs and shows me the url: files/main.php/param (note that the extension has been added ".php" to the main file).

Does anyone know what may be due and how to fix it?

Joseph
  • 335
  • 1
  • 3
  • 13
  • If I call the url `http://localhost/files/main/` (With slash at the end) it executes the file `main.php` and shows the url `files/main.php/` – Joseph Jul 15 '18 at 02:57
  • I'm a little late to this party (thread closed), so I have to comment here for future readers. The problem is MultiViews is enabled. Just add Options -MultiViews to your .htaccess to disable it and the extensionless urls will stop redirecting – BillyGalbreath Jun 02 '23 at 00:46

1 Answers1

0

You need to enable the mod_rewrite and create a virtual host. Follow this tutorial to do it: https://artisansweb.net/how-to-enable-mod_rewrite/

Nicolas Talichet
  • 309
  • 3
  • 16
  • 1
    No, what I need is to disable the current redirection that WAMP has. I have the "mod_rewrite" plugin disabled and, even so, the server keeps redirecting the request as I mentioned in the main question... – Joseph Jul 15 '18 at 03:18