html - htaccess 在 CHROME 中重写两次

标签 html .htaccess mod-rewrite url-rewriting favicon

我的 htaccess 中有以下内容,因此我可以通过 domain.com/whatever 而不是 domain.com/index.php/view/whatever 访问页面.所以这从 URL 中删除了 index.php/view。这在除 chrome 之外的所有浏览器中都可以正常工作。 Chrome 两次重写页面。我注意到这一点的方式是因为我在页面上有一个计数器。每次页面加载时,计数器都会增加 2。如果我删除重写规则,则计数器会正常工作并增加 1。为什么重写在 chrome 中发生两次。 Firefox 和 IE 只加载页面一次。

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/view/$1 [L]

PS: viewwhatever 既不是文件也不是文件夹。它们是动态生成的。

最佳答案

您的 htaccess 没有问题。确保您的页面上有一个有效的图标。这让我一度发疯,花了我一段时间才弄明白。

<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico">

关于html - htaccess 在 CHROME 中重写两次,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8275865/

相关文章:

javascript - 如何在使用 bootstrap 4 时右对齐我的按钮

html - Angular 模态 : How to reuse the same html in modal as well as in the page

apache - .htaccess 密码保护不断要求输入密码

performance - .htaccess mod_rewrite 性能

html - bootstrap css 重复元素随机跳过

html - 关于基于 Chromium 的桌面应用程序的想法?

apache - .htaccess 错误的 HTML 500 错误页面

php - 允许虚荣 URL 和 session 的单个 .htaccess 文件

php - 如何使用 Apache Mod_rewrite 删除 php 扩展,同时保留 GET 参数?

.htaccess - 简单的重写规则问题