Php 重写COND can';如果文件中有重音,则找不到该文件
我有以下.htaccess文件:Php 重写COND can';如果文件中有重音,则找不到该文件,php,.htaccess,Php,.htaccess,我有以下.htaccess文件: <IfModule mod_rewrite.c> Options +FollowSymlinks RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^.*$ index.php [L] </IfModule> 选项+FollowSy
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ index.php [L]
</IfModule>
选项+FollowSymlinks
重新启动发动机
重写基/
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则^.*$index.php[L]
如果不是文件或目录,它会将所有内容重定向到index.php。它可以正常工作,但是当文件名中有重音时,它会将url重定向到index.php,因此RewriteCond无法检测到它是一个现有文件。例如(两个文件都存在):
这是有效的:(给我PDF)
但事实并非如此:(将我重定向到index.php)
问题是我没有访问web服务器conf的权限,因为它位于webhosting服务器上
系统是Windows Server 2008 R2 Web Server Edition Service Pack 1(由PhpInfo提供)
Web服务器:Microsoft IIS/7.5根据CD001的评论,我发现IIS可以自动转换.htacess文件,但并非始终100%工作。因此,我通过手动将
.htaccess
文件转换为web.config
文件,解决了这个问题。转换的文件是:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Rule 1">
<match url="^(.*)$" ignoreCase="false" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
</conditions>
<action type="Rewrite" url="index.php" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
将其保存为网页根目录中的
web.config
,以使其正常工作并删除.htacess
Apache版本?我可以在Win7开发设备上使用XAMMP(Apache 2.4.3)。@CD001编辑了我的文章,但它是Microsoft IIS/7.5。这是你的问题,他们,.htaccess
,mod_rewrite
等都是特定于Apache的-我相信IIS使用Web.config XML文件。这可能很有用:@CD001根据您提供的信息,我可以将.htaccess文件转换为Web.config文件进行修复。请把它作为答案贴出来,这样我就可以接受了。