使用mod_rewrite删除.php扩展可以工作,但标记页面不能

使用mod_rewrite删除.php扩展可以工作,但标记页面不能,php,.htaccess,mod-rewrite,tags,Php,.htaccess,Mod Rewrite,Tags,我有这样的.htaccess文件: RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^(.*)$ $1.php RewriteRule (.*)/sites/([^a-zA-Z][0-9_/]*$) $1.php?sites=$2 [L] RewriteRule (.*)/sites/([0-9_/]*)/(

我有这样的.htaccess文件:

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
RewriteRule (.*)/sites/([^a-zA-Z][0-9_/]*$) $1.php?sites=$2 [L]
RewriteRule (.*)/sites/([0-9_/]*)/(.*) $3 [L]
RewriteRule (.*)/sites/(.*) $2 [L]
RewriteRule tags_xml/(.*).xml tags/display_xml.php?tag=$1 [L]
RewriteRule news_xml/(.*).xml rss.php?site=$1 [L]
RewriteRule tags/([ÄĂ“ĹŚĄŻŹĆĹęółśążźćńa-zA-Z0-9%\ ]*)/([^a-zA-Z][0-9_/]*$) tags/display.php?tag=$1&page=$2 [L]
RewriteRule tags/([ÄĂ“ĹŚĄŻŹĆĹęółśążźćńa-zA-Z0-9%\ ]+) tags/display.php?tag=$1 [L]
RewriteRule news/([0-9]*)/([0-9]*)/([^a-zA-Z][0-9]*)/(.*).html$ kom.php?id_b=$1&id_n=$2&kom_page=$3 [L]
RewriteRule news/([0-9]*)/([0-9]*)/(.*).html$ kom.php?id_b=$1&id_n=$2 [L]
RewriteRule news/([0-9]*)/([0-9]*)/([^a-zA-Z][0-9]*)/(.*) $4 [L]
RewriteRule news/([0-9]*)/([0-9]*)/(.*) $3 [L]
RewriteCond %{THE_REQUEST} ^.*index.php.*
现在当我进去的时候

www.domain.com/file

而不是

www.domain.com/file.php

它工作正常,但当我进入

www.domain.com/tags/Bank

我没有发现这样的标签错误。此外,此文件夹中的其他脚本仅显示“未找到此类标记”

以前的工作守则是:

RewriteEngine On
RewriteBase /
RewriteRule (.*)/sites/([^a-zA-Z][0-9_/]*$) $1.php?sites=$2 [L]
RewriteRule (.*)/sites/([0-9_/]*)/(.*) $3 [L]
RewriteRule (.*)/sites/(.*) $2 [L]
RewriteRule tags_xml/(.*).xml tags/display_xml.php?tag=$1 [L]
RewriteRule news_xml/(.*).xml rss.php?site=$1 [L]
RewriteRule tags/([ĘÓŁŚĄŻŹĆŃęółśążźćńa-zA-Z0-9%\ ]*)/([^a-zA-Z][0-9_/]*$) tags/display.php?tag=$1&page=$2 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule tags/([ĘÓŁŚĄŻŹĆŃęółśążźćńa-zA-Z0-9%\ ]+) tags/display.php?tag=$1 [L]
RewriteRule news/([0-9]*)/([0-9]*)/([^a-zA-Z][0-9]*)/(.*).html$ kom.php?id_b=$1&id_n=$2&kom_page=$3 [L]
RewriteRule news/([0-9]*)/([0-9]*)/(.*).html$ kom.php?id_b=$1&id_n=$2 [L]
RewriteRule news/([0-9]*)/([0-9]*)/([^a-zA-Z][0-9]*)/(.*) $4 [L]
RewriteRule news/([0-9]*)/([0-9]*)/(.*) $3 [L]
RewriteCond %{THE_REQUEST} ^.*index.php.*
更新: 好的,再次阅读htaccess后,我注意到您使用了以下内容:

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
在某些系统上,这将指向您的文件系统,所以添加文档根目录可能对您有用。像这样:

RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php

解决方案是在末尾添加:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^\.]+)$ $1.php [NC,L]

“以前的工作代码”-如果有效,为什么不使用它?它适用于标记,但不适用于从文件中删除.php。对于这个问题,您的所有代码都是必需的吗?你能去掉不必要的行吗?这只是翻译错误。这是正确的,它不工作。你行的tagi/显示部分?我需要在这里从波兰语翻译它。如果你不直接复制和粘贴问题代码,我会非常小心。在这种情况下,这是可以理解的,但这只是一个提示,您可能忽略了代码中的错误,并在此处键入了不同的内容。@bjorn-在您的代码中,没有php的两个页面都不工作,标记也不工作,因此,我们需要找到更好的解决方案,但我仍然认为我的answare为您提供了解决问题所需的帮助?