我用xampp和flight php在电脑上开发了一个网站,一切都很好。我决定使用windows plesk帐户将其上传到godaddy中,当我试图访问我的网站时,它会产生404错误。我知道index.php被执行了,但是重写不起作用。例如,当我访问mysite.com/login时,它会产生404错误。我使用了默认的飞行php-htaccess。
RewriteEngine On
RewriteBase /httpdocs/uem-um-gov.com
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [QSA,L]
我发现服务器使用的是IIS,而不是apache,所以我用Web.config替换了.htaccess。
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<clear />
<rule name="Rewrite to index.php" stopProcessing="true">
<match url="^(.*)$" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="index.php" appendQueryString="true" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>