One specific word in my URL triggers a 404 error

huangapple go评论59阅读模式
英文:

One specific word in my URL triggers a 404 error

问题

这是问题。我的.htaccess将所有URL重定向到index.php。

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]

RewriteRule ^(.*)$ index.php [L,QSA]

在我的index.php中,我只是放置了一个echo "test";来尝试它。对于每个URL,它都有效,除了一个,但是,如果我键入"http://localhost/mysite/inventaire/",Apache返回404错误,我不明白为什么,这毫无意义。我在另一台电脑上进行了这个项目的工作,从来没有遇到这个问题。单词"inventaire"似乎触发了这个错误,我无法理解为什么...

我尝试修改http.conf,就像我在SO上看到的那样,但没有帮助。最后,我在我的应用程序中将单词更改为"inventaires",它就像魔法一样正常工作,太奇怪了...

英文:

here's the thing. My .htaccess redirects all the URL to index.php.

RewriteEngine On

RewriteCond %{REQUEST_FILENAME}  -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]

RewriteRule ^(.*)$ index.php [L,QSA]

In my index.php, I just put an echo "test"; to try it. For every URL it works, everyone of them BUT, if I type "http://localhost/mysite/inventaire/", apache returns a 404 error and I don't understand why, it doesn't make any sense. I work on this project in an other computer and I never had this problem. The word "inventaire" seems to trigger this error and I can't understand why...

I tried to modify the http.conf as I saw on SO but it didn't help. I finally changed the word with "inventaires" in my app and it works like a charm, so strange...

答案1

得分: 1

> 我在我的目录中添加了两个 SQL 文件,但我不记得了,其中一个叫做“inventaire.sql”,所以当我尝试执行“mysite/inventaire”时,它指向了这个 SQL 文件...

这将意味着你启用了 MultiViews,否则 inventaire 不会映射到 inventaire.sql(一个实际文件,然后被第一个规则阻止)。MultiViews 应该是禁用的(默认情况下是禁用的)。

要显式禁用 MultiViews,请在 .htaccess 文件顶部添加以下内容:

Options -MultiViews
英文:

> I added two SQL files in my directory and didn't remember that, and one of them was called "inventaire.sql", so when I was trying to do "mysite/inventaire" it pointed on this SQL file...

That would imply you have MultiViews enabled, otherwise inventaire would not map to inventaire.sql (a physical file, which then gets blocked by the first rule). MultiViews should be disabled (it is by default).

To explicitly disable MultiViews, add the following to the top of the .htaccess file:

Options -MultiViews

huangapple
  • 本文由 发表于 2023年5月18日 00:40:18
  • 转载请务必保留本文链接:https://go.coder-hub.com/76274365.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定