我使用我的htaccess从URL中删除index.php。在我的PC上,应用程序正常工作。我使用Xampp。但是,当我上传到服务器时,它只显示了主页,我无法在Windows Live Server中没有index.php访问其他控制器
hta访问在Windows Live Server中无法使用您的项目的根文件夹中的Web.config文件,并在此类零件下添加重写代码。当然可以帮助您。
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Rule" stopProcessing="true">
<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" />
<add input="{URL}" pattern="^/favicon.ico$" ignoreCase="false" negate="true" />
</conditions>
<action type="Rewrite" url="index.php/{R:1}" appendQueryString="true" />
</rule>
</rules>
</rewrite>
<directoryBrowse enabled="true" />
<defaultDocument>
<files>
<clear />
<add value="Default.htm" />
<add value="Default.asp" />
<add value="index.htm" />
<add value="Default.aspx" />
<add value="index.php" />
<add value="index.html" />
<add value="index.pl" />
<add value="default.html" />
<add value="Default.cshtml" />
</files>
</defaultDocument>
<httpProtocol>
<customHeaders>
<clear />
</customHeaders>
</httpProtocol>
</system.webServer>
</configuration>
我也有类似的问题。将其放在您的 .htaccess 文件上,将其放在root Directory中。这为我解决了问题。
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index.php|images|robots.txt)
RewriteRule ^(.*)$ index.php?/$1 [L]