Strange redirection

Asked

Viewed 247 times

4

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

How do I disable this "redirect" as it is giving problem in my . htacess

I use apache 2.22, PHP 5.4.9 on Ubuntu 12.04 and 13.04 (Tested both dist and gives the same problem) on Cloud Digitalocean.

2 answers

2


Given the circumstances, I believe it’s caused by the use of the "Multiviews"

example:

Options Indexes FollowSymLinks MultiViews

If you don’t want to use it, just remove it

Options Indexes FollowSymLinks

If "redirect" is not caused by "Multiviews", it is probably some url rewriting rule (mod_rewrite).

There are other possibilities, but I find it difficult that it is something outside of these two hypotheses.

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

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

  • Friends, thank you so much the problem was exactly the Multiviews. Using the editor nano(English) I ran the following command to edit the settings: sudo nano /etc/apache2/sites-available/default. I removed the Multivire from the configuration node and after apache reboot the subject has been solved.

1

Apache by default is configured to work with the file index.html. Only if it is not located will it try to locate the index.php.

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

DirectoryIndex index.php

So he should go first to the index.php.

If you want him to fail to locate the index.php go find the 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 a / at the end of the directory name.

That 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.

  • The default value seems to vary from installation to installation as in the documentation only the index.html. Curious in my all these have higher priority than that: index.pl index.cgi index.asp index.shtml.

  • @Gustavorodrigues It’s true, it varies from installation to installation, but what I always see is that the index.php is always for last. In the suggested way we are basically passing the same to first. (I must say that I personally use as comes, index.html first, as it facilitates with maintenance pages...) Ps: Thanks for the link to the documentation, I will put in the reply :)

  • In XAMPP is after this list that I put there, so after it comes a huge list of alternatives, default.html for example. I wonder why the .php stay after the .html. Defect is not, would be compatibility?

  • Compatibility yes. I’m no longer on the computer but tomorrow I can elaborate the answer to that.

  • @Gustavorodrigues I already did a research, but I could not find anything "official" to corroborate my interpretation of being a compatibility issue. If I find it I’ll add to the answer.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.