Weird redirect

4

Even without .htaccess and without the apache rewriter module active if I call mydomain.com / page it will search first page.html if it does not find it it will go to page.php.

How do I disable this "redirect" because it is giving trouble in my .htacess

I use Apache 2.22, PHP 5.4.9 on Ubuntu 12.04 and 13.04 (I tested both dist and gives the same problem) in the DigitalOcean Cloud.

    
asked by anonymous 04.03.2014 / 01:10

2 answers

2

Under the circumstances, I believe it is caused by the use of "MultiViews"

example:

Options Indexes FollowSymLinks MultiViews

If you do not want to use it, just remove it

Options Indexes FollowSymLinks

If the "redirection" is not caused by "MultiViews", it is probably some url rewriting rule (mod_rewrite).

There are other possibilities, but I find it difficult to be out of these two hypotheses.

off: Sorry for commenting, but I did not understand the term "defect" in the comments above. Is this a term used in Portugal? In online dictionaries of Portuguese from Portugal, this word has the same meaning as Brazilian Portuguese. Anyway, the correct word would be "default."

[updating] A more appropriate title for this topic would be "Apache interpreting a directory as a .php or .html file."

    
04.03.2014 / 06:09
1

The default Apache is configured to work with the index.html file. Only if it is not found will you try to find index.php .

A quick way to resolve this is to put a .htaccess file with the following directive at the root of your domain:

DirectoryIndex index.php

So, it should go first to index.php .

If you want it to fail to find index.php go to index.html :

DirectoryIndex index.php index.html

Documentation for the DirectoryIndex Directive (English) :

  

The DirectoryIndex directive sets the list of resources to look for, when the client requests an index of the directory by specifying it at the end of the directory name.

What translated:

  

The DirectoryIndex directive defines the list of resources to look for, when the client requests a directory index, specifying the / at the end of the directory name.

    
04.03.2014 / 01:29